コード例 #1
0
        public void Spawn()
        {
            for (int i = 0; i < 25; i++)
            {
                bool ally  = i == 10 || i == 2 || i == 18;
                bool block = i == 4 || i == 13 || i == 22;

                string prefabName = ally ? "Ally" : (block ? "Block" : "Enemy");

                GridObject gridObject = Spawn(new Vector3(i % 5, i / 5, 0), _gameObjects[prefabName]);

                if (ally)
                {
                    AllyObject.AttackType attackType = i == 10 ? AllyObject.AttackType.round : (i == 2 ? AllyObject.AttackType.line : AllyObject.AttackType.three_random);
                    string spriteName = i == 10 ? "annunaki" : (i == 2 ? "hierarchy" : "terran");

                    gridObject.AddProperty(new AllyObject(gridObject, attackType, (Vector3 pos) => ShowDamageEnemyEffect(pos)));
                    gridObject.AddProperty(new SelectableWithArrows(gridObject));
                    gridObject.AddProperty(new ImageChanger(gridObject, _sprites [spriteName]));
                }
                else if (!block)
                {
                    int idx = UnityEngine.Random.Range(0, 2);

                    gridObject.AddProperty(new EnemyObject(gridObject, idx == 0?3:4, (Vector3 pos) => ShowDamagePlayerEffect(pos)));
                    gridObject.AddProperty(new ImageChanger(gridObject, _sprites [idx == 0?"commander-bot-2":"sp01_mercenary"]));
                }
            }
        }
コード例 #2
0
        void OnDestroyGridObject(Vector3 gridPos)
        {
            Vector3 spawnPos = gridPos;

            spawnPos.y = 5;
            while (_grid.GetFromCell(spawnPos) != null)
            {
                spawnPos += Vector3.up;
            }
            GridObject gridObject = Spawn(spawnPos, _gameObjects["Enemy"]);

            int idx = UnityEngine.Random.Range(0, 2);

            gridObject.AddProperty(new EnemyObject(gridObject, idx == 0?3:4, (Vector3 pos) => ShowDamagePlayerEffect(pos)));
            gridObject.AddProperty(new ImageChanger(gridObject, _sprites [idx == 0?"commander-bot-2":"sp01_mercenary"]));

            _coroutineStarter.StartCoroutine(waitAndMove(gridPos));
        }
コード例 #3
0
        GridObject Spawn(Vector3 gridPos, GameObject template)
        {
            GameObject gameObject = GameObject.Instantiate(template);

            gameObject.transform.SetParent(_canvas.transform);
            gameObject.transform.localScale = Vector3.one;

            GridObject gridObject = new GridObject(gameObject, _grid, OnDestroyGridObject);

            gridObject.GridPos = gridPos;
            //gridObject.AddProperty (new SelectableWithImageColor (heroGridObject));
            gridObject.AddProperty(new MovingObject(gridObject, _coroutineStarter));
            return(gridObject);
        }