public override void Execute(object data)
    {
        Spawner          spawner = GetModel <Spawner>();
        SpawnMonsterArgs c       = data as SpawnMonsterArgs;

        spawner.SpawnMonster(c.MonsterID);
    }
Example #2
0
    /// <summary>
    /// 回合开始,开始出怪
    /// </summary>
    private IEnumerator RunRound()
    {
        _allRoundsComplete = false;
        for (int i = 0; i < _rounds.Count; i++)
        {
            //回合信息
            StartRoundArgs startRoundArgs = new StartRoundArgs();
            startRoundArgs.RoundIndex = i;
            startRoundArgs.RoundTotal = RoundTotal;

            SendEvent(Consts.E_StartRound, startRoundArgs);

            Round round = _rounds[i];

            for (int j = 0; j < round.Count; j++)
            {
                //出怪信息
                SpawnMonsterArgs spawnMonsterArgs = new SpawnMonsterArgs();
                spawnMonsterArgs.MosterType = round.Monster;

                SendEvent(Consts.E_SpawnMonster, spawnMonsterArgs);

                yield return(new WaitForSeconds(Spawn_Interval));
            }

            _roundIndex++;

            if (i < round.Count - 1)
            {
                yield return(new WaitForSeconds(Round_Interval));
            }
        }
        _allRoundsComplete = true;
    }
Example #3
0
    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;
        }
    }
Example #4
0
    IEnumerator RunRound()
    {
        for (int i = 0; i < m_Rounds.Length; i++)
        {
            //回合开始事件
            StartRoundArgs e = new StartRoundArgs
            {
                RoundIndex = i,
                RoundTotal = RoundTotal
            };

            SendEvent(Consts.E_StartRound, e);

            Round round = m_Rounds[i];
            for (int j = 0; j < round.Count; j++)
            {
                //出怪间隙
                yield return(new WaitForSeconds(SPAWN_INTERVAL));

                //出怪事件
                SpawnMonsterArgs ee = new SpawnMonsterArgs
                {
                    MonsterType = round.Monster
                };
                SendEvent(Consts.E_SpawnMonster, ee);
            }

            //回合间隙
            yield return(new WaitForSeconds(ROUND_INTERVAL));
        }

        //出怪流程
        m_AllRoundsComplete = true;
    }
Example #5
0
    public override void HandleEvent(string eventName, object data)
    {
        switch (eventName)
        {
        case Consts.E_EnterScene:
            SceneArgs sce = data as SceneArgs;
            if (sce.SceneIndex == 3)
            {
                MapV = GetComponent <MapV>();
                MapModel MapM = GetModel <MapModel>();
                MapV.MapVInit(MapM);
                MapV.Draw();
                MapV.CompleteMap += Complete;
            }

            break;

        case Consts.E_SpawnMonster:
            SpawnMonsterArgs s = data as SpawnMonsterArgs;
            Debug.Log("生成怪物:" + s.MonsterID);
            SpawnMonster(s.MonsterID);
            break;

        case Consts.E_SpawnTower:
            Debug.Log("生成塔");
            break;
        }
    }
Example #6
0
    IEnumerator RunRound()
    {
        for (int i = 0; i < m_Rounds.Count; i++)
        {
            //回合开始事件
            StartRoundArgs e = new StartRoundArgs();
            e.RoundIndex = i;
            e.RoundTotal = RoundTotal;
            SendEvent(Consts.E_StartRound, e);

            Round round = m_Rounds[i];

            for (int k = 0; k < round.Count; k++)
            {
                //出怪间隙
                yield return(new WaitForSeconds(SPAWN_INTERVAL));

                //出怪事件
                SpawnMonsterArgs ee = new SpawnMonsterArgs();
                ee.MonsterType = round.Monster;
                SendEvent(Consts.E_SpawnMonster, ee);
            }

            //回合间隙
            yield return(new WaitForSeconds(ROUND_INTERVAL));
        }

        //出怪完成
        m_AllRoundsComplete = true;
    }
Example #7
0
    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);

                //加载萝卜
                Vector3[] path = m_Map.Path;
                Vector3   pos  = path[path.Length - 1];
                SpawnLuobo(pos);
            }
            break;

        case Consts.E_SpawnMonster:
            SpawnMonsterArgs e1 = data as SpawnMonsterArgs;
            SpawnMonster(e1.MonsterType);
            break;
        }
    }
    IEnumerator RunRound()
    {
        m_RoundIndex       = -1;
        m_AllRoundComplete = false;
        // m_AllRoundComplete = false;
        for (int i = 0; i < m_Rounds.Count; i++)
        {
            //设置回合
            m_RoundIndex = i;
            //回合开始事件
            StartRoundArgs e = new StartRoundArgs();
            e.RoundIndex = m_RoundIndex;
            e.RoundTotal = RoundTotal;
            SendEvent(Consts.E_StartRound, e);

            Round round = m_Rounds[i];
            for (int j = 0; j < round.Count; j++)
            {
                //出怪间隔
                yield return(new WaitForSeconds(SPAWN_INTERVAL));

                //出怪事件
                SpawnMonsterArgs ee = new SpawnMonsterArgs()
                {
                    MonsterID = round.Monster
                };

                SendEvent(Consts.E_SpawnMonster, ee);
                //最后一波出怪完成
                if ((i == m_Rounds.Count - 1) && (j == round.Count - 1))
                {
                    //出怪完成
                    m_AllRoundComplete = true;
                }
            }


            //回合数自加
            //m_RoundIndex = m_RoundIndex + 1;
            //等待回合事件间隔
            // if(i<m_Rounds.Count-1)

            if (!m_AllRoundComplete)
            {
                //回合间隙
                yield return(new WaitForSeconds(ROUND_INTERVAL));
            }
        }
        //回合结束事件
    }
Example #9
0
    /// <summary>
    /// 协程:运行一个回合
    /// </summary>
    /// <returns></returns>
    IEnumerator RunRound()
    {
        //回合开始
        yield return(new WaitForSeconds(ROUND_INTERVAL));

        StartRoundArgs e = new StartRoundArgs
        {
            RoundIndex   = m_RoundIndex,
            RoundTotal   = RoundTotal,
            MonsterTotal = m_Rounds[m_RoundIndex].TotalMonster
        };

        Debug.Log("回合开始");
        SendEvent(Consts.E_StartRound, e);//发送一个回合开始的事件

        List <MonsterGroup> round = m_Rounds[m_RoundIndex].TheRound;
        SpawnMonsterArgs    x     = new SpawnMonsterArgs();

        for (int k = 0; k < round.Count; k++)
        {
            MonsterGroup group = round[k];

            SendEvent(Consts.E_SpawnMonsterGroups, group);//发送一个显示怪物群的消息
            for (int j = 0; j < group.count; j++)
            {
                //出怪间隙
                yield return(new WaitForSeconds(SPAWN_INTERVAL));

                //出怪事件
                x.MonsterID = group.monsterID;
                //Debug.Log("生成怪物"+ group.monsterID);
                if (x == null)
                {
                    Debug.Log("x无效");
                }
                else
                {
                    SendEvent(Consts.E_SpawnMonster, x); //发送一个生成怪物的命令
                }
            }
        }
        m_RoundIndex++;
    }
Example #10
0
    IEnumerator RunRound()
    {
        m_RoundIndex        = -1;
        m_AllRoundsComplete = false;

        for (int i = 0; i < m_Rounds.Count; i++)
        {
            //设置回合
            m_RoundIndex = i;

            //回合开始事件
            StartRoundArgs e = new StartRoundArgs();
            e.RoundIndex = m_RoundIndex;
            e.RoundTotal = RoundTotal;
            SendEvent(Consts.E_StartRound, e);

            Round round = m_Rounds[i];

            for (int k = 0; k < round.Count; k++)
            {
                //出怪间隙
                yield return(new WaitForSeconds(SPAWN_INTERVAL));

                //出怪事件
                SpawnMonsterArgs ee = new SpawnMonsterArgs();
                ee.MonsterID = round.Monster;
                SendEvent(Consts.E_SpawnMonster, ee);

                //最后一波出怪完成
                if ((i == m_Rounds.Count - 1) && (k == round.Count - 1))
                {
                    //出怪完成
                    m_AllRoundsComplete = true;
                }
            }

            if (!m_AllRoundsComplete)
            {
                //回合间隙
                yield return(new WaitForSeconds(ROUND_INTERVAL));
            }
        }
    }
Example #11
0
    public override void HandleEvent(string eventName, object data)
    {
        switch (eventName)
        {
            case Consts.E_EnterScene:
                SceneArgs e0 = (SceneArgs)data;
                if (e0.SceneIndex == 3)
                {
                    m_Map = GetComponent<Map>();

                    //获取数据
                    GameModel gModel = GetModel<GameModel>();
                    m_Map.LoadLevel(gModel.PlayLevel);
                }
                break;
            case Consts.E_SpawnMonster:
                SpawnMonsterArgs e = (SpawnMonsterArgs)data;
                Spawn(e.MonsterType);
                break;
        }
    }
Example #12
0
    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;
        }
    }