Пример #1
0
    private void DoActionFire()
    {
        Direction l_LookingDirection;

        if (GetLookingDirection(m_LastModelPos, m_ModelHitPos, out l_LookingDirection))
        {
            //Reorient
            Unit l_Target;
            if (m_EquipedItem != null && TryHitUnit(m_LastModelPos, GetNextPosition(m_LastModelPos, l_LookingDirection), m_EquipedItem.range, out l_Target) && m_EquipedItem.TryUse())
            {
                m_CurrentUnit.Action();

                if (l_Target.TakeHit())
                {
                    DestroyUnit(m_ModelHitPos);
                }

                SetModeMove();
            }
        }
        else
        {
            SelectionMethode();
        }
    }
Пример #2
0
 public void UnitAction()
 {
     if (!currectActiveUnit)
     {
         return;
     }
     currectActiveUnit.Action();
 }
Пример #3
0
    void Selecting()
    {
        highlight = null;
        bool onPlayer  = false;
        bool hasPlayer = Unit.player != null;

        if (Mouse.Hit(out RaycastHit hit, LayerMask.GetMask("Unit")))
        {
            highlight = hit.transform.GetComponent <Unit>();
            if (hasPlayer)
            {
                onPlayer = playerTeam.memebers.Contains(highlight);
            }
        }
        bool showInfo     = Input.GetKey(KeyCode.LeftAlt);
        bool action       = Input.GetKeyDown(KeyCode.Space);
        bool selectPlayer = Mouse.LeftDown && onPlayer;

        foreach (Unit unit in Unit.All)
        {
            if (action)
            {
                unit.Display(Unit.Highlight.Nothing);
            }
            else if (unit == highlight)
            {
                Unit.Highlight state = Unit.Highlight.Attack | Unit.Highlight.Outline | Unit.Highlight.Info;
                if (onPlayer)
                {
                    state |= Unit.Highlight.Moving;
                }
                unit.Display(state);
            }
            else
            {
                Unit.Highlight state = Unit.Highlight.Nothing;
                if (showInfo)
                {
                    state |= Unit.Highlight.Info | Unit.Highlight.Attack;
                }
                unit.Display(state);
            }
        }
        Hint.self.space.SetActive(!selectPlayer && !action);
        Hint.self.alt.SetActive(!showInfo && !action);
        Hint.self.control.SetActive(onPlayer && !selectPlayer && !action);
        Hint.self.shift.SetActive(false);
        Hint.self.ctrl.SetActive(selectPlayer && !action);
        Hint.self.right.SetActive(selectPlayer && !action);
        Hint.self.confirm.SetActive(selectPlayer && !action);
        if (selectPlayer)
        {
            selected = highlight as Player;
            selected.ControlStart();
            stateUpdate = Control;
        }
        else if (action)
        {
            stateUpdate = null;
            Team.NonUser.NpcDecision();
            if (hasPlayer)
            {
                playerTeam.memebers.ForEach(x => (x as Player).StatusReset());
            }
            Unit.Action(() =>
            {
                Unit.Alive.RemoveAll(x => x.isDie);
                Team.All.RemoveAll(x => x.memebers.Count == 0);
                Team.NonUser.RemoveAll(x => x.memebers.Count == 0);
                if (Team.All.Count == 1 && !testing)
                {
                    stateUpdate = null;
                    DelayEvent.Create(2f, () =>
                    {
                        Arena.ContestComplete(Team.All.First());

                        Team.All.Clear();
                        Team.NonUser.Clear();
                        Unit.All.Clear();
                        Unit.Alive.Clear();
                    });
                }
                else
                {
                    Team.All.ForEach(x => x.Update());
                    stateUpdate = Selecting;
                }
            });
        }
    }