Exemple #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;
            }
        }
Exemple #2
0
        public void Update(int filterIndex, Selection selection, float deltaTime)
        {
            foreach (var s in selection)
            {
                C_MonsterFindPath c = s.GetComp <C_MonsterFindPath>();


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

                if (c.target.Next == null)
                {
                    C_PlayerProperties p = selection.context.SelectOne <C_PlayerProperties>().GetComp <C_PlayerProperties>();
                    OnArrive(p);
                    selection.context.Remove(s.id);
                    return;
                }


                c.target = c.target.Next;
                s.SetRotation((c.target.Value.position - s.GetPosition()).ToRotation());
                s.GetComp <C_TargetPos>().targetPos = c.target.Value.position;

                if (s.HasComp <C_MoveStart>())
                {
                    s.RemoveComp(s.GetComp <C_MoveStart>());
                }
                if (s.HasComp <C_MoveEnd>())
                {
                    s.RemoveComp(s.GetComp <C_MoveEnd>());
                }
                //s.AddComp<C_MoveToPos>();
            }
        }
Exemple #3
0
 private void OnArrive(C_PlayerProperties p)
 {
     p.hpRest -= 1;
     p.hpRest  = Mathf.Max(p.hpRest, 0);
 }