public override void Execute(object data) { SpawnSkillArgs e = data as SpawnSkillArgs; GameModel gm = GetModel <GameModel>(); //TODO update the count of skill switch (e.skillType) { case SkillType.NULL: throw new ArgumentNullException("skillType"); case SkillType.FireBall: gm.FireBallCount--; gm.isUsedFireBall = true; break; case SkillType.ArrowRain: gm.ArrowRainCount--; gm.isUsedArrowRain = true; break; case SkillType.Lighting: gm.LightingCount--; gm.isUsedLighting = true; break; default: throw new ArgumentException("Wrong SkillType", "skillType"); } }
public void SpawnSkillOnTouchDown(Vector2 tapPos) { GameModel gm = MVC.GetModel <GameModel>(); Debug.Log(gm.CurrentSkillType); if (gm.CurrentSkillType == SkillType.NULL) { return; } if (gm.GetSkillState(gm.CurrentSkillType)) { return; } if (gm.GetSkillCount(gm.CurrentSkillType) <= 0) { 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) { SpawnSkillArgs e1 = new SpawnSkillArgs() { skillType = gm.CurrentSkillType, camp = Camp.YELLOW, pos = spawnPos }; MVC.SendEvent(Consts.E_SpawnSkill, e1); } }
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; } }