Beispiel #1
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);
        }
Beispiel #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));
        }