XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

AshfallFrontier

【Unity】灰烬边境,一款生存策略游戏

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Collections;
using Ashfall.Core;
using Ashfall.Runtime;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace Ashfall.Tests
{
    public sealed class FloorIsolationTests
    {
        [UnityTest]
        public IEnumerator SameCoordinatesOnDifferentFloorsUseIsolatedPhysics()
        {
            var sim = new GameSimulation(WorldFactory.Create(), ContentCatalog.CreateDefault());
            var a = sim.Connect("a", "一楼", Species.Human); var b = sim.Connect("b", "二楼", Species.Brood);
            a.location = WorldFactory.At("lab", 0, new V2()); b.location = WorldFactory.At("lab", 1, new V2());
            sim.World.Space("lab").floors[0].walls.Add(new WallState { id = "test.wall", bounds = new Box2(new V2(), new V2(2, 2)), height = 3 });
            using (var physics = new FloorPhysics())
            {
                physics.Synchronize(sim.World, 1); yield return null; physics.Simulate(.05f);
                Assert.That(physics.Blocked(a.location, .2f), Is.True);
                Assert.That(physics.Blocked(b.location, .2f), Is.False);
            }
            yield return null;
        }
        [UnityTest]
        public IEnumerator RuntimeBootsAndWormCanStartOffline()
        {
            yield return null;
            var session = Object.FindFirstObjectByType<GameSession>();
            Assert.That(session, Is.Not.Null);
            session.UseTestSave(System.IO.Path.Combine(Application.temporaryCachePath, "AshfallTests", System.Guid.NewGuid().ToString("N") + ".sav"));
            session.StartOffline(Species.Brood, "test", false);
            yield return null;
            Assert.That(session.LocalPlayer.IsWorm, Is.True);
            Assert.That(Object.FindFirstObjectByType<WorldView>().Camera.orthographic, Is.True);
            session.Stop(); session.UseTestSave(null);
        }
    }
}