public override void HandleEvent(string eventName, object data) { switch (eventName) { case Consts.E_EnterScene: SceneArgs sceneArgs = data as SceneArgs; if (sceneArgs.SceneId == 3) { //加载数据 GameModel gameModel = GetModel <GameModel>(); //加载地图 _map = GetComponent <Map>(); _map.LoadLevel(gameModel.PlayLevel); _map.OnTileClick += MapOnOnTileClick; //加载萝卜 SpawnLuobo(_map.Path[_map.Path.Length - 1]); } break; case Consts.E_SpawnMonster: SpawnMonsterArgs spawnMonsterArgs = data as SpawnMonsterArgs; SpawnMonster(spawnMonsterArgs.MosterType); break; case Consts.E_SpawnTower: SpawnTowerArgs spawnTower = data as SpawnTowerArgs; SpawnTower(spawnTower.TowerId, spawnTower.Pos); break; default: break; } }
public override void Execute(object data) { Spawner spawner = GetModel <Spawner>(); SpawnTowerArgs a = data as SpawnTowerArgs; spawner.SpawnTower(a.TowerID, a.Position); }
void OnMouseDown() { //if (!m_Enough) //return; SpawnTowerArgs e = new SpawnTowerArgs() { Position = m_CreatePosition, TowerID = m_Info.ID }; SendMessageUpwards("SpawnTower", e, SendMessageOptions.DontRequireReceiver); }
void OnMouseDown() { if (!m_Enough) { return; } gm.Score -= m_Info.BasePrice; SpawnTowerArgs e = new SpawnTowerArgs() { Position = m_CreatePosition, TowerID = m_Info.ID }; SendMessageUpwards("SpawnTower", e, SendMessageOptions.DontRequireReceiver); }
public void SpawnTower(int ID) { CloseShop(); if (towerPrice[ID] <= money) { GameModel gameModel = GetModel <GameModel>(); SpawnTowerArgs args = new SpawnTowerArgs { TowerID = ID, Position = gameModel.MainCharater.transform.position }; SendEvent(Consts.E_SpawnTower, args); Money -= towerPrice[ID]; } else { NoMoney.SetTrigger("Show"); } }
void OnMouseDown() { if (m_Tower.name >= 3 || gm.Score < m_Tower.BasePrice) { return; } gm.Score -= m_Tower.BasePrice; UpgradeTowerArgs e = new UpgradeTowerArgs() { tower = m_Tower }; SendMessageUpwards("UpgradeTower", e, SendMessageOptions.DontRequireReceiver); SpawnTowerArgs e2 = new SpawnTowerArgs() { Position = m_Tower.transform.position, TowerID = m_Tower.name + 3 }; SendMessageUpwards("SpawnTower", e2, SendMessageOptions.DontRequireReceiver); }
public override void HandleEvent(string eventName, object data) { switch (eventName) { case Consts.E_EnterScene: SceneArgs e0 = data as SceneArgs; if (e0.SceneIndex == 3) { //获取数据 GameModel gModel = GetModel <GameModel>(); //加载地图 m_Map = GetComponent <Map>(); m_Map.LoadLevel(gModel.PlayLevel); m_Map.OnTileClick += map_OnTileClick; //HU //加载萝卜 Vector3[] path = m_Map.Path; Vector3 pos = path [path.Length - 2]; int Herotype = int.Parse(gModel.PlayLevel.Name); SpawnHero(Herotype, pos); pos.y += 0.5f; gModel.des = pos; //HU } break; case Consts.E_SpawnEnemy: SpawnEnemyArgs e1 = data as SpawnEnemyArgs; SpawnEnemy(e1.EnemyType); break; case Consts.E_SpawnTower: SpawnTowerArgs e2 = data as SpawnTowerArgs; SpawnTower(e2.Position, e2.TowerID); break; } }
void OnMouseDown() { //金币是否足够 // if(!m_IsEnough) // return; ////创建塔的类型TowerID //int towerID = m_Info.ID; ////创建位置 //Vector3 position = m_Position; ////参数 //object[] args = {towerID, position}; ////消息冒泡 /// s SpawnTowerArgs e = new SpawnTowerArgs() { Position = m_Position, TowerID = m_Info.ID, }; SendMessageUpwards("OnSpawnTower", e, SendMessageOptions.RequireReceiver);//找不到报错 }
public override void HandleEvent(string eventName, object data) { switch (eventName) { case Consts.E_EnterScene: SceneArgs e0 = data as SceneArgs; if (e0.SceneIndex == 3) { //获取地图组件 m_Map = GetComponent <Map>(); m_Map.OnTileClick += map_OnTileClick; //加载地图 GameModel gModel = GetModel <GameModel>(); m_Map.LoadLevel(gModel.PlayLevel); //加载萝卜 Vector3[] path = m_Map.Path; Vector3 luoboPos = path[path.Length - 1]; SpawnLuobo(luoboPos); } break; case Consts.E_SpawnMonster: SpawnMonsterArgs e1 = data as SpawnMonsterArgs; SpawnMonster(e1.MonsterID); break; case Consts.E_SpawnTower: SpawnTowerArgs e2 = data as SpawnTowerArgs; SpawnTower(e2.Position, e2.TowerID); break; default: break; } }
void OnSpawnTower(SpawnTowerArgs e) { // HideAllPopups(); SendEvent(Consts.E_SpawnTower, e); }
void SpawnTower(SpawnTowerArgs e) { //HideAllPanels(); SendEvent(Consts.E_SpawnTower, e); }