Exemplo n.º 1
0
        public ItemBox Create(ItemData data, Hex hex, Player owner)
        {
            ItemBox itemBox;

            if (data.type == ItemType.Element)
            {
                var elementData = (ElementData)data;
                itemBox = GameObject.Instantiate(Resources.Load<ItemBox>("Prefabs/Play/Element"));

                if (elementData.kind == ElementKind.Random || elementData.kind == ElementKind.None)
                {
                    elementData.kind = (ElementKind)URandom.Range(1, 4);
                }

                switch (elementData.kind)
                {
                    case ElementKind.Red:
                        data.color = new Color(1, 0, 0);
                        break;
                    case ElementKind.Green:
                        data.color = new Color(0, 1, 0);
                        break;
                    case ElementKind.Blue:
                        data.color = new Color(0, 0, 1);
                        break;
                }

            }
            else if (data.type == ItemType.Other)
            {
                itemBox = GameObject.Instantiate(Resources.Load<ItemBox>("Prefabs/Play/Bomb"));

                if (owner.Index == 0)
                    data.color = new Color(1, 0, 0);
                else
                    data.color = new Color(0, 1, 0);
            }
            else
            {
                itemBox = null;
            }

            var position = hex.GroundCenter;
            position.y += 2;
            itemBox.t.position = position;

            itemBox.Initialize(owner, data);

            return itemBox;
        }
Exemplo n.º 2
0
        public void Initialize(Player owner, ItemData data)
        {
            Owner = owner;

            if (data.type == ItemType.Element)
                Item = new Element(this, (ElementData)data);
            else
                Item = new BombItem(this, (BombData)data);

            lifeTime = data.lifeTime;
            hasLifeTime = 0 != lifeTime;

            r.material = Resources.Load<Material>("Models/Materials/whiteMat");
            r.material.mainTexture = Resources.Load<Texture>("Models/whiteColor");

            r.material.color = data.color;

            var yOffset = !data.overrideOffsetK ? r.bounds.size.y * 0.5f : r.bounds.size.y * data.yOffsetK;

            DefineStartHex(yOffset);
        }
Exemplo n.º 3
0
 public void DeactivatePlayer(Player player)
 {
     if (activePlayer == player) player = null;
 }
Exemplo n.º 4
0
 public void ActivatePlayer(Player player)
 {
     activePlayer = player;
 }
Exemplo n.º 5
0
 public bool IsEnemy(Player player)
 {
     return enemies.ContainsKey(player.Index);
 }
Exemplo n.º 6
0
 public bool IsAlly(Player player)
 {
     return player == this || allies.ContainsKey(player.Index);
 }
Exemplo n.º 7
0
            public static List<Player> Build(string[] names, int[][] enemies, int[][] allies)
            {
                NeutralPassive = new Player("Neutral Passive", -1);
                NeutralAggressive = new Player("Neutral Aggressive", -2);

                int n = 0;
                foreach (var name in names)
                {
                    players.Add(new Player(name, n));
                    n++;
                }

                int i = 0;

                foreach (var player in players)
                {
                    if (enemies != null)
                        for (int j = 0; j < enemies[i].Length; j++)
                            player.enemies.Add(enemies[i][j], players[enemies[i][j]]);

                    if (allies != null)
                        for (int j = 0; j < allies[i].Length; j++)
                            player.allies.Add(allies[i][j], players[allies[i][j]]);

                    player.enemies.Add(NeutralAggressive.Index, NeutralAggressive);
                    NeutralAggressive.enemies.Add(player.Index, player);

                    i++;
                }

                return players;
            }