コード例 #1
0
 private void Awake()
 {
     #region Singleton
     //Singleton only for 'GameScene'
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     #endregion
     grid = FindObjectOfType <Grid>();
     //RemoveDifficyltyDuples();
     EndGameBoard.transform.localScale = Vector2.zero;
     resetButton = EndGameBoard.GetComponentInChildren <Button>();
     resetButton.onClick.AddListener(grid.Reset);
 }
コード例 #2
0
ファイル: Cell.cs プロジェクト: AlexSpeleers/Unity-O-X
 private void Awake()
 {
     main = GameObject.FindObjectOfType <MovingLogic>();
 }
コード例 #3
0
        public void NestedComputationTest()
        {
            int numRCS = 0;


            SimulationRun run = new SimulationRun(
                new BaseDB.ConfigContainer()
            {
                extent = new Int3(3), r = 1f / 8, m = 1f / 16
            },
                new ShardID(Int3.One, 0));

            Vec3 outlierCoords = Simulation.MySpace.Min;

            var    crossingLogic  = new MovingLogic(new Vec3(-1, 0, 0));
            Entity crosser        = new Entity(new EntityID(Guid.NewGuid(), Simulation.MySpace.Min), Vec3.Zero, crossingLogic, null);
            Vec3   crossingTarget = crosser.ID.Position + crossingLogic.Motion;

            foreach (var n in Simulation.Neighbors)
            {
                n.OnPutRCS = (decoded, gen) =>
                {
                    numRCS++;

                    Assert.AreEqual(gen, 1);


                    //RCS decoded = new RCS(rcs);

                    Assert.IsTrue(decoded.IsFullyConsistent);
                    //RCS.GenID id = new RCS.GenID(rcs.NumericID,0);
                    //Link lnk = Simulation.Neighbors.Find(id.ID.ToShard);
                    //Assert.IsNotNull(lnk);

                    if (n.WorldSpace.Grow(Simulation.Ranges.Transmission).Contains(outlierCoords))
                    {
                        Assert.IsFalse(decoded.CS.IsEmpty);
                    }
                    else
                    {
                        Assert.IsTrue(decoded.CS.IsEmpty);
                    }

                    if (n.WorldSpace.Contains(crossingTarget))
                    {
                        Assert.IsNotNull(decoded.CS.FindMotionOf(crosser.ID.Guid));
                    }
                }
            }
            ;


            run.FeedEntities(
                new Entity[]
            {
                new Entity(
                    new EntityID(Guid.NewGuid(), Simulation.MySpace.Center),
                    Vec3.Zero,
                    new ExceedingMovementLogic(),
                    //new EntityTest.FaultLogic.State(),
                    null),

                new Entity(
                    new EntityID(Guid.NewGuid(), outlierCoords),
                    Vec3.Zero,
                    new StationaryLogic(),
                    //new EntityTest.FaultLogic.State(),
                    null),
                crosser
            }
                );



            var inter = run.BeginAdvanceTLG(true);

            foreach (var p in inter.Intermediate.localChangeSet.NamedSets)
            {
                int expected = p.Key == "motions" || p.Key == "advertisements" ? 3 : 0;
                Assert.AreEqual(expected, p.Value.Size);
            }

            Assert.AreEqual(inter.Generation, 1);
            Assert.AreEqual(Simulation.NeighborCount, numRCS);
            //comp.

            {
                Link inbound = Simulation.Neighbors.Find(new Int3(0, 1, 1));
                RCS  inRCS   = new RCS(new EntityChangeSet(), new InconsistencyCoverage(inbound.ICExportRegion.Size));
                Simulation.FetchNeighborUpdate(run.tlgEntry, inbound, inRCS.Export());
            }

            var rs = run.CompleteAdvanceTLG(false);

            //check if most outer cells are 1 (one full-edge incoming RCS):
            var core     = rs.SDS.IC.Sub(Int3.One, rs.SDS.IC.Size - 2);
            int edgeSize = InconsistencyCoverage.CommonResolution - 2;

            Assert.AreEqual(rs.SDS.IC.OneCount, rs.SDS.IC.Size.Product - core.Size.Product - edgeSize * edgeSize, edgeSize.ToString());
            Assert.IsTrue(rs.SDS.IC.OneCount > 0);
            Assert.IsTrue(core.OneCount == 0);


            Assert.AreEqual(rs.Generation, 1);
            Assert.AreEqual(rs.SDS.FinalEntities.Length, 2);
            Assert.IsFalse(rs.SDS.HasEntity(crosser.ID.Guid));

            var check = Simulation.CheckMissingRCS(rs);

            Assert.IsFalse(check.AllThere);
            Assert.IsFalse(check.AnyAvailableFromNeighbors);
            Assert.AreEqual(check.missingRCS, numRCS - 1);
            Assert.IsTrue(check.predecessorIsConsistent);
            Assert.AreEqual(check.rcsAvailableFromNeighbor, 0);
            Assert.AreEqual(check.rcsRestoredFromDB, 0);
        }