示例#1
0
        public void TestZoneGeneric()
        {
            Zone zone = new Zone();

            OID cid1 = new OID();
            OID cid2 = new OID();
            OID cid3 = new OID();

            OID oid = zone.Get(0);

            Assert.IsNull(oid);

            zone.Add(cid1);
            zone.Add(cid2);
            zone.Add(cid3);
            Assert.IsTrue(zone.Has(cid1));
            Assert.AreEqual(zone.Count, 3);
            Assert.AreEqual(zone.Get(0), cid3);
            Assert.AreEqual(zone.Get(zone.Count - 1), cid1);
            Assert.ThrowsException <IndexOutOfRangeException>(() => zone.Get(-1));
            Assert.ThrowsException <IndexOutOfRangeException>(() => zone.Get(zone.Count));

            OID pop = zone.Pop();

            Assert.AreEqual(pop, cid3);
            Assert.AreEqual(zone.Count, 2);
            Assert.AreEqual(zone.Get(0), cid2);

            Assert.ThrowsException <ArgumentException>(() => zone.Add(cid2));
            Assert.ThrowsException <ArgumentException>(() => zone.Remove(cid3));

            zone.Push(pop);
            Assert.AreEqual(zone.Count, 3);
            Assert.AreEqual(zone.Get(0), cid3);
        }
示例#2
0
        public void AreasAggregateTest()
        {
            f1.Add(f2);
            zoo.AddField(f1);

            Assert.AreEqual(zoo.areas[0], f1);
            Assert.AreEqual(zoo.areas[1], f2);
        }
示例#3
0
    public static void InitGameAndZoneInfo()
    {
        Awake();
        string[] inputs;
        inputs           = Console.ReadLine().Split(' ');
        game.playerCount = int.Parse(inputs[0]);
        game.myIndex     = game.myId = int.Parse(inputs[1]);
        game.zoneCount   = int.Parse(inputs[2]);
        game.linkCount   = int.Parse(inputs[3]);

        for (int i = 0; i < game.zoneCount; i++)
        {
            Zone newZone = new Zone();
            inputs         = Console.ReadLine().Split(' ');
            newZone.id     = int.Parse(inputs[0]);
            newZone.income = int.Parse(inputs[1]);
            Zone.Add(newZone.id, newZone);
        }
        for (int i = 0; i < game.linkCount; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            Zone zone1 = Zone.Get(int.Parse(inputs[0]));
            Zone zone2 = Zone.Get(int.Parse(inputs[1]));
            zone1.AddLink(zone2);
            zone2.AddLink(zone1);
        }
    }
示例#4
0
 public static void InitGameAndZoneInfo(GameData game, long now)
 {
     Timer.StartTime = now;
     if (Awake != null)
     {
         Awake();
     }
     string[] inputs;
     inputs            = Console.ReadLine().Split(' ');
     game.playerCount  = int.Parse(inputs[0]);
     GameData.sMyId    = game.myId = int.Parse(inputs[1]);
     GameData.sEnemyId = game.enemyId = game.myId == 0 ? 1 : 0;
     game.zoneCount    = int.Parse(inputs[2]);
     game.linkCount    = int.Parse(inputs[3]);
     for (int i = 0; i < game.zoneCount; i++)
     {
         Zone newZone = new Zone();
         inputs         = Console.ReadLine().Split(' ');
         newZone.id     = int.Parse(inputs[0]);
         newZone.income = int.Parse(inputs[1]);
         Zone.Add(newZone.id, newZone);
     }
     for (int i = 0; i < game.linkCount; i++)
     {
         inputs = Console.ReadLine().Split(' ');
         Zone zone1 = Zone.Get(int.Parse(inputs[0]));
         Zone zone2 = Zone.Get(int.Parse(inputs[1]));
         zone1.AddLink(zone2);
         zone2.AddLink(zone1);
     }
 }
示例#5
0
 public static void AddRange(this Zone <IPlayable> zone, List <IPlayable> src)
 {
     for (int i = 0; i < src.Count; ++i)
     {
         zone.Add(src[i]);
     }
 }
示例#6
0
        private static void AddStar(Zone zone)
        {
            Star star = new Star();

            star.Template      = new BaseTemplate();
            star.Template.Name = "Primary";

            zone.Add(star);
        }
示例#7
0
        public override Zone CreateZone()
        {
            Console.WriteLine("Процесс создания зоны начат");
            PirateShipBuilder builder = new PirateShipBuilder();

            obj = new Zone("Зона");
            obj.Add(builder.CreateShip());
            Console.WriteLine("Процесс создания зоны закончен");
            return((Zone)obj);
        }
示例#8
0
        public void ComponentHirerarchyTest()
        {
            f1.Add(f2);
            f1.Add(bearAviary);
            f2.Add(giraffeAviary);
            f2.Add(wolfAviary);
            zoo.AddField(f1);

            Assert.AreEqual(f1.Composites()[1], bearAviary);
            Assert.AreEqual(f2.Composites()[0], giraffeAviary);
            Assert.AreEqual(f2.Composites()[1], wolfAviary);
        }
示例#9
0
        public static void Insert(this Zone <IPlayable> zone, int ind, IPlayable p)
        {
            var popped = new List <IPlayable>();

            for (int i = zone.Count - 1; i >= ind; --i)
            {
                popped.Add(zone.Remove(zone[i]));
            }
            zone.Add(p);
            zone.AddRange(popped);
        }
示例#10
0
        public void MoveTo(Zone target)
        {
            var source = Zone;

            if (source == target)
            {
                throw new System.Exception("Tried to move " + Name + " from " + source.Name + " to " + target.Name);
            }
            source.Remove(this);
            target.Add(this);
            Zone = target;
            foreach (var observer in moveObservers)
            {
                observer(this, source, target);
            }
        }
示例#11
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            entity.CannotSuspend           = true;
            entity.CannotSuspendByDistance = true;
            Zone      zone      = entity.GetOrCreate <Zone>("Zone");
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            zone.Add(new Binding <Matrix>(zone.Transform, transform.Matrix));
            this.SetMain(entity, main);

            entity.Add("Exclusive", zone.Exclusive);
            entity.Add("Priority", zone.Priority);
            entity.Add("Build", zone.Build);
            entity.Add("DetailedShadows", zone.DetailedShadows);
            entity.Add("RiftProof", zone.RiftProof);
        }
示例#12
0
        public void Setup()
        {
            var data = new CardData {
                Name = "Test", DataId = 1
            };

            CardDatabase.GetInstance().AddItem(data);
            testEntity = EntityFactory.Create(typeof(Card), TestDefaults.MainPlayer);

            testZone = new Zone <Card> {
                MaxSize = 1
            };
            testZone.OnItemAdded += delegate
            {
                mustBeTrue = true;
            };
            testZone.OnItemRemoved += delegate
            {
                mustBeTrue2 = true;
            };
            testZone.Add(testEntity.AsActor().AsCard());
        }
示例#13
0
        public FireworksDemo(Image image)
            : base(image)
        {
            DrawQueue.Add(this);

            _dragZone = new RectangleZone
                        (
                0.ToSimUnits(),
                (WorldHeight * 2 / 3.0).ToSimUnits(),
                500.ToSimUnits(),
                400.ToSimUnits()
                        );
            _dragZone.Add(_drag);

            _windZone = new RectangleZone
                        (
                0.ToSimUnits(),
                (WorldHeight * 1 / 3.0).ToSimUnits(),
                500.ToSimUnits(),
                (WorldHeight * 2 / 3.0).ToSimUnits()
                        );
            _windZone.Add(_wind);
        }
示例#14
0
        public virtual int SpawnPlayableShip(string requester, string requestedType, string requestedName)
        {
            string typeToUse = requestedType;

            // something wants a new player ship to be spawned
            if (typeToUse == string.Empty)
            {
                typeToUse = GetPlayerShipTemplate();
            }

            ShipTemplate template = TemplateDatabase.GetTemplate(typeToUse) as ShipTemplate;

            if (!GetPlayableShips().Contains(template) && GetPlayableShips().Count > 0)
            {
                template = GetPlayableShips()[0];
            }

            Zone spawnZone = ZoneManager.FindZone(GetDefaultZoneName());

            if (spawnZone == null)
            {
                var zones = ZoneManager.GetZones();
                if (zones.Length == 0)
                {
                    return(-1); // no zones to spawn a ship in
                }
                spawnZone = zones[0];
            }

            var ship = new Ship(template);

            ship.Name = FilterShipName(requestedName, requestedType);

            spawnZone.Add(ship);

            return(ship.GUID);
        }
示例#15
0
 private void Move(Zone origin, Card card, Zone destination)
 {
     origin.Remove(card);
     destination.Add(card);
     card.Zone = destination;
 }
示例#16
0
    static void Main(string[] args)
    {
        GameData game = GameData.Instance = new GameData();

        Awake();

        DebugLog("Awake game");
        string[] inputs;
        inputs           = Console.ReadLine().Split(' ');
        game.playerCount = int.Parse(inputs[0]);             // the amount of players (2 to 4)
        game.myIndex     = game.myId = int.Parse(inputs[1]); // my player ID (0, 1, 2 or 3)
        game.zoneCount   = int.Parse(inputs[2]);             // the amount of zones on the map
        game.linkCount   = int.Parse(inputs[3]);             // the amount of links between all zones

        for (int i = 0; i < game.zoneCount; i++)
        {
            Zone newZone = new Zone();
            inputs         = Console.ReadLine().Split(' ');
            newZone.id     = int.Parse(inputs[0]); // this zone's ID (between 0 and zoneCount-1)
            newZone.income = int.Parse(inputs[1]); // the amount of Platinum this zone can provide per game turn
            Zone.Add(newZone.id, newZone);
        }
        for (int i = 0; i < game.linkCount; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            Zone zone1 = Zone.Get(int.Parse(inputs[0]));
            Zone zone2 = Zone.Get(int.Parse(inputs[1]));
            zone1.AddLink(zone2);
            zone2.AddLink(zone1);
        }

        foreach (Zone z in Zone.GetZones())
        {
            z.zoneType = Zone.GetZoneTypeWithoutBigResearch(z, z.linkedZone);
        }

        DebugLog("Data initialized");

        int iFrame = 0;

        // game loop
        while (true)
        {
            game.frame = iFrame;
            if (iFrame == 0)
            {
                DebugLog("Start game");
                Start();
            }
            DebugLog("Frame" + (iFrame));
            UpdateBefore();

            game.players[0].platinum = int.Parse(Console.ReadLine());
            for (int i = 0; i < Zone.Count; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                Zone zone = Zone.Get(int.Parse(inputs[0]));
                zone.SetArmiesState(int.Parse(inputs[1]), int.Parse(inputs[2]), int.Parse(inputs[3]), int.Parse(inputs[4]), int.Parse(inputs[5]));
                if (iFrame == 0 && zone.data.ownerId != -1)
                {
                    SetPlayerOrigineZone(zone.data.ownerId, zone);
                    //game.map.SetZone(76, 76, zone);
                }
            }

            Update();
            iFrame++;
            //Console.WriteLine("WAIT"); // first line for movement commands, second line for POD purchase (see the protocol in the statement for details)
            //Console.WriteLine("1 73");
        }
    }