Ejemplo n.º 1
0
        public void Update(int filterIndex, Selection selection, float deltaTime)
        {
            switch (filterIndex)
            {
            case 0:
                isNewFrame = selection.First().GetComp <C_FrameIndex>().newFrame;
                break;

            case 1:
                if (!isNewFrame)
                {
                    return;
                }

                Entity e = selection.First();

                C_LevelData        data   = e.GetComp <C_LevelData>();
                C_PlayerProperties player = e.GetComp <C_PlayerProperties>();
                C_MonsterGenerator m      = e.GetComp <C_MonsterGenerator>();

                Rect   rect = new Rect(50, 100, 400, 100);
                string text = $"wave:{m.currentWave} coins:{player.coins} hp:{player.hpRest}/{player.hpMax}";
                guiActions.Clear();

                guiActions.Add(() => {
                    GUI.Label(rect, text, new GUIStyle(GUI.skin.label)
                    {
                        fontSize = 20
                    });
                });

                break;
            }
        }
Ejemplo n.º 2
0
        public void Update(int filterIndex, Selection selection, float deltaTime)
        {
            foreach (var s in selection)
            {
            }

            Entity             e = selection.First();
            C_MonsterGenerator c = e.GetComp <C_MonsterGenerator>();

            if (c.current == null)
            {
                return;
            }

            if (c.timeForNextWave > 0)
            {
                c.timeForNextWave -= deltaTime;
                if (c.timeForNextWave > 0)
                {
                    return;
                }
            }

            if (c.timeForNextWave < 0)
            {
                float fixTime = -c.timeForNextWave;
                c.timeForNextWave = 0;
                c.timer           = fixTime;
                return;
            }

            c.timer += deltaTime;

            while (c.timer > c.current.interval)
            {
                c.timer -= c.current.interval;

                MonsterEntry mm      = CfgProxy.Instance.Get <MonsterEntry>(c.current.monsterID);
                Entity       monster = context.CreateMonster(mm);

                c.counter++;

                if (c.counter == c.current.count)
                {
                    if (c.currentWave < c.monsterSequences.Count - 1)
                    {
                        c.currentWave++;
                        c.current = c.monsterSequences[c.currentWave];
                        c.ResetCounter();
                    }
                    else
                    {
                        c.current = null;
                    }

                    break;
                }
            }
        }