Exemple #1
0
    public override void HandleEvent(string eventName, object data)
    {
        switch (eventName)
        {
        case Consts.E_SpawnSoldier:
            SpawnSoldierArgs e1 = data as SpawnSoldierArgs;
            if (e1.camp == Camp.YELLOW)
            {
                gm.ConsumeEnergy(Game.Instance.StaticData.GetSoldierInfo(e1.arm).Cost);
                UpdateEnergyShow(gm.Energy);
            }
            break;

        default:
            break;
        }
    }
Exemple #2
0
    IEnumerator RandomSpawnEnemyCoroutine()
    {
        while (true)
        {
            yield return(new WaitForSeconds(5));

            List <Transform> SpawnerList = new List <Transform>(greenSpanerTrans);
            int count = UnityEngine.Random.Range(1, 4);
            for (int i = 0; i < count; i++)
            {
                int index          = UnityEngine.Random.Range(0, SpawnerList.Count);
                SpawnSoldierArgs e = new SpawnSoldierArgs()
                {
                    arm = (Arm)UnityEngine.Random.Range(1, 6), camp = Camp.GREEN, pos = SpawnerList[index].position
                };
                SendEvent(Consts.E_SpawnSoldier, e);
                SpawnerList.RemoveAt(index);
            }
        }
    }
Exemple #3
0
    public override void HandleEvent(string eventName, object data)
    {
        switch (eventName)
        {
        case Consts.E_EnterScene:
            SceneArgs e0 = data as SceneArgs;
            if (e0.SceneIndex == 2)
            {
                Game.Instance.Sound.PlayBGM("Game");
            }
            StartCoroutine(RandomSpawnEnemyCoroutine());
            break;

        case Consts.E_SpawnSoldier:
            SpawnSoldierArgs e1 = data as SpawnSoldierArgs;
            SpawnSoldier(e1.arm, e1.camp, e1.pos);
            break;

        case Consts.E_SpawnSkill:
            SpawnSkillArgs e2 = data as SpawnSkillArgs;
            SpawnSkill(e2.skillType, e2.camp, e2.pos);
            break;

        case Consts.E_ShowSHop:
            MVC.GetView <UIShop>().Show();
            break;

        case Consts.E_Win:
            MVC.GetView <UIWin>().Show();
            break;

        case Consts.E_Lose:
            MVC.GetView <UILose>().Show();
            break;

        default:
            break;
        }
    }
Exemple #4
0
    public void SpawnSoldierOnTouchDown(Vector2 tapPos)
    {
        Arm currentSpawnType = MVC.GetModel <GameModel>().CurrentSpawnType;

        if (currentSpawnType == Arm.NULL)
        {
            return;
        }

        if (Game.Instance.StaticData.GetSoldierInfo(currentSpawnType).Cost > MVC.GetModel <GameModel>().Energy)
        {
            return;
        }

        Vector3    spawnPos = Vector3.zero;
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(tapPos), out hit))
        {
            if (hit.transform.tag != Tags.GROUND)
            {
                return;
            }

            spawnPos = hit.point;
        }

        if (spawnPos != null)
        {
            SpawnSoldierArgs e1 = new SpawnSoldierArgs()
            {
                arm = currentSpawnType, camp = Camp.YELLOW, pos = spawnPos
            };
            MVC.SendEvent(Consts.E_SpawnSoldier, e1);
        }
    }
Exemple #5
0
 public override void Execute(object data)
 {
     SpawnSoldierArgs e = data as SpawnSoldierArgs;
 }