Exemplo 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;
            }
        }
Exemplo n.º 2
0
        public void Update(int filterIndex, Selection selection, float deltaTime)
        {
            Entity      e = selection.First();
            C_LevelLoad c = e.GetComp <C_LevelLoad>();

            if (c.isDone)
            {
                e.RemoveComp(c);
                return;
            }

            c.loadingPercent++;

            C_LevelData data = null;

            switch (c.loadingPercent)
            {
            case 10:
                c.level   = CfgProxy.Instance.Get <LevelEntry>(1);
                c.mapData = c.level.mapData;
                break;

            case 12:
                data = e.GetComp <C_LevelData>();
                if (data == null)
                {
                    data = e.AddComp <C_LevelData>();
                }
                data.paths.Clear();
                c.mapData.pathTiles.ForEach(o => data.paths.AddLast(o));
                data.monsterSequences.Clear();
                data.monsterSequences.AddRange(c.level.waveInfo.waves);
                break;

            case 20:
                e.AddComp <C_PlayerProperties>();
                break;

            case 28:
                foreach (var tileData in c.mapData.functionTiles)
                {
                    switch (tileData.type)
                    {
                    case GameDefine.TileType.Slot:
                        Entity slot = selection.context.Create(Recipes.Get <SlotRecipe>());
                        slot.SetPosition(tileData.position);
                        break;

                    default:
                        break;
                    }
                }
                break;

            case 35:
                c.mapData.pathTiles.ForEach(o =>
                {
                    var t = context.Add();
                    t.AddComp <C_Rotation>();
                    t.AddComp <C_Position>().position = o.position;
                    t.AddComp <C_Renderer>();
                    var asset      = t.AddComp <C_Asset>();
                    asset.mesh     = "Mesh/Tile";
                    asset.material = "Materials/Default";
                });
                break;

            case 49:
                data = e.GetComp <C_LevelData>();
                if (data == null)
                {
                    data = e.AddComp <C_LevelData>();
                }
                var mg = e.AddComp <C_MonsterGenerator>();
                mg.InitMonsters(data.monsterSequences);
                break;

            case 50:
                c.isDone = true;
                break;

            default:
                break;
            }
        }