Esempio n. 1
0
    private void UpdateAbilityTarget()
    {
        if (HasAttacked)
        {
            CurrentTurnState = TurnState.ExitTurn;
        }

        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);

        // Perform attack when target is clicked on && Display target information when hovering over target
        if (hit != false && hit.collider != null)
        {
            // Return from method if hit item is part of the blocking layer or is the current active human
            if (hit.collider.tag == "Blocking")
            {
                return;
            }

            TextColorPack colorPack = ActiveHuman.Ability.CategoryColor();

            if (Input.GetMouseButtonDown(0))
            {
                // Stop traps and collectables from being hit by heals and support abilities
                if (ActiveHuman.Ability.Category == SkillCategory.Support || ActiveHuman.Ability.Category == SkillCategory.Heal)
                {
                    if (hit.collider.tag == "Trap" || hit.collider.tag == "Collectable")
                    {
                        return;
                    }
                }

                // Check if skill will land then either perform attack or display miss msg
                if (IsHit(hit.collider.gameObject))
                {
                    ActiveHuman.Ability.Perform(hit.collider.gameObject, ActiveHuman.CharData, base.floatingTextMgr);
                }
                else
                {
                    base.DisplayMissMsg(hit.transform.position, colorPack.fontColor, colorPack.outlineColor);
                }

                ActiveHuman.soundStatus = SoundStatus.Ability;

                ChangeState(TurnState.ExitTurn);
            }

            if (hit.collider.tag == "Player" || hit.collider.tag == "Enemy")
            {
                DisplayStateMessage(TurnState.UsingAbility, "Use <color=" + colorPack.fontColor.ColorAsHex() + "> " + ActiveHuman.Ability.Name + " </color> on: " + hit.collider.name);
            }
        }
        else
        {
            DisplayStateMessage(TurnState.UsingAbility, "Select a target.");
        }

        DisplayMousePointer(TurnState.UsingAbility, CursorsType.Skill);
    }
Esempio n. 2
0
    public void OnMouseEnter()
    {
        PlayerController playerController = BattleManager.GetPlayerController;
        IAttack          attack           = BattleManager.ActiveCharacter.Attack;
        TextColorPack    colorPack        = attack.CategoryColor();

        txt.text = "Use <color=" + colorPack.fontColor.ColorAsHex() + ">" + attack.Name + "</color> (+" + attack.RecoveryCost + " recovery)";
        txt.gameObject.SetActive(true);
    }
Esempio n. 3
0
    public void UpdateAttackTarget()
    {
        if (HasAttacked)
        {
            CurrentTurnState = TurnState.ExitTurn;
        }

        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);

        // Perform attack when target is clicked on && Display target information when hovering over target
        if (hit != false && hit.collider != null)
        {
            // Return from method if hit item is part of the blocking layer or is the current active human
            if (hit.collider.tag == "Blocking" || hit.collider.gameObject == ActiveHuman.gameObject)
            {
                return;
            }

            TextColorPack colorPack = ActiveHuman.Attack.CategoryColor();

            if (Input.GetMouseButtonDown(0))
            {
                ActiveHuman.SetFacingDirection((ActiveHuman.Position - hit.transform.position).x);
                ActiveHuman.PlayShootAnim();


                if (IsHit(hit.collider.gameObject))
                {
                    stats.hits++;
                    stats.shotsFired++;
                    ActiveHuman.soundStatus = SoundStatus.Hit;
                    ActiveHuman.Attack.Perform(hit.collider.gameObject, ActiveHuman.CharData, base.floatingTextMgr);
                }
                else
                {
                    stats.misses++;
                    stats.shotsFired++;
                    ActiveHuman.soundStatus = SoundStatus.Miss;
                    base.DisplayMissMsg(hit.transform.position, colorPack.fontColor, colorPack.outlineColor);
                }

                ActiveHuman.Recovery += ActiveHuman.Attack.RecoveryCost;
                ChangeState(TurnState.ExitTurn);
            }

            DisplayStateMessage(TurnState.Attacking, "Use <color=" + colorPack.fontColor.ColorAsHex() + ">" + ActiveHuman.Attack.Name + "</color> On: " + hit.collider.name);
        }
        else
        {
            DisplayStateMessage(TurnState.Attacking, "Select a target.");
        }

        DisplayMousePointer(TurnState.Attacking, CursorsType.Skill);
    }
Esempio n. 4
0
    private void UseDefensive(Humanoid target)
    {
        if (target == null)
        {
            Debug.Log("Can't find defensive target");
        }

        float targetDist = Vector2.Distance(target.transform.position, ActiveHuman.Position);

        // Move if possible and hasn't already moved
        AttemptMove(target.Position);

        // Attempt to hit nearest target if any movement is complete
        if (HasMoved)
        {
            Humanoid closestTarget = Closest(TeamPlayers);

            if (closestTarget == null)
            {
                HasAttacked = true;
                return;
            }

            targetDist = Vector2.Distance(closestTarget.transform.position, ActiveHuman.Position);

            // Perform attack if less than 140% of optimal distance
            if (targetDist < optimalDistance * 1.4f)
            {
                ActiveHuman.SetFacingDirection((ActiveHuman.Position - closestTarget.Position).x);
                ActiveHuman.PlayShootAnim();

                TextColorPack colorPack = ActiveHuman.Attack.CategoryColor();

                if (IsHit(target.gameObject))
                {
                    ActiveHuman.Attack.Perform(closestTarget.gameObject, ActiveHuman.CharData, base.floatingTextMgr);
                    ActiveHuman.soundStatus = SoundStatus.Hit;
                }
                else
                {
                    DisplayMissMsg(closestTarget.transform.position, colorPack.fontColor, colorPack.outlineColor);
                    ActiveHuman.soundStatus = SoundStatus.Miss;
                }

                HasAttacked = true;
            }
        }

        Debug.Log("HasMoved: " + HasMoved);
        Debug.Log("HasAttacked: " + HasAttacked);
    }
Esempio n. 5
0
    private void UpdateAbilityArea()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //ActiveHuman.soundStatus = SoundStatus.Ability;
        }
        // Display Area and position AOE field
        aoeHandler.SetToActive(true);
        aoeHandler.SetPosition(Input.mousePosition);

        Vector3 mousePos       = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        float   targetDistance = Vector3.Distance(ActiveHuman.Position, mousePos);

        TextColorPack colorPack = ActiveHuman.Ability.CategoryColor();

        if (ActiveHuman.Ability.IsInRange(targetDistance))
        {
            // Perform Ability on targets and change state when mouse is clicked
            if (Input.GetMouseButtonDown(0))
            {
                if (ActiveHuman.Ability.Category == SkillCategory.Attack)
                {
                    ActiveHuman.soundStatus = SoundStatus.Ability;
                    DmgEffectManager.CreateHit(aoeHandler.transform.position);
                }

                ActiveHuman.Ability.Perform(aoeHandler.targets.ToArray(), ActiveHuman.CharData, floatingTextMgr);

                aoeHandler.SetToActive(false);

                ActiveHuman.Recovery += ActiveHuman.Ability.RecoveryCost;

                ChangeState(TurnState.ExitTurn);
            }

            aoeHandler.SetColour(Color.green);
            DisplayStateMessage(TurnState.UsingAbility, "Select an area to use <color=" + colorPack.fontColor.ColorAsHex() + ">" + ActiveHuman.Ability.Name + "</color>.");
        }
        else
        {
            aoeHandler.SetColour(Color.red);
            DisplayStateMessage(TurnState.UsingAbility, "<color=red>Out of range</color> of user.");
        }

        DisplayMousePointer(TurnState.UsingAbility, CursorsType.Hide);
        DisplayAoeField(TurnState.UsingAbility);
        //hud.GetCursorManager.CurrentCursor = CursorsType.Hide;
    }
Esempio n. 6
0
    // Perform a heal or move towards target
    private void UseHeal(Humanoid target)
    {
        if (ActiveHuman.Ability.Type == SkillType.Single)
        {
            float targetDist = Vector2.Distance(target.transform.position, ActiveHuman.Position); // get Target Position
            //bool moveCloser = false;

            // Perform attack if less than 140% of optimal distance otherwise move towards player
            if (targetDist < optimalDistance * 1.4f)
            {
                TextColorPack colorPack = ActiveHuman.Ability.CategoryColor();

                // Test if heal landed or missed
                if (IsHit(target.gameObject))
                {
                    ActiveHuman.Ability.Perform(target.gameObject, ActiveHuman.CharData, base.floatingTextMgr);
                    ActiveHuman.soundStatus = SoundStatus.Ability;
                }
                else
                {
                    DisplayMissMsg(target.transform.position, colorPack.fontColor, colorPack.outlineColor);
                }

                HasAttacked = true; // Ends turn
            }
            else
            {
                AttemptMove(target.Position);
            }
        }
        else if (ActiveHuman.Ability.Type == SkillType.Multiple)
        {
            // is any team members close enough?
            // Get Position between player member
            // is within 140% of optimal range?
            // no? then move closer
            //ActiveHuman.soundStatus = SoundStatus.Ability;
        }

        NewDelay();
    }
Esempio n. 7
0
    // Perform an attack or move towards target
    private void UseAttack(Humanoid target)
    {
        if (ActiveHuman.Attack.Type == SkillType.Single)
        {
            float targetDist = Vector2.Distance(target.transform.position, ActiveHuman.Position); // get Target Position
            //bool moveCloser = false;

            // Perform attack if less than 140% of optimal distance otherwise move towards player
            if (targetDist < optimalDistance * 1.4f)
            {
                ActiveHuman.SetFacingDirection((ActiveHuman.Position - target.Position).x);
                ActiveHuman.PlayShootAnim();

                TextColorPack colorPack = ActiveHuman.Attack.CategoryColor();

                bool performSupportAbility = false;

                if (ActiveHuman.CharData.type == UnitType.Support)
                {
                    float roll = UnityEngine.Random.value * 100;
                    performSupportAbility = (roll >= 50) ? true : false;
                    colorPack             = ActiveHuman.Ability.CategoryColor();
                }

                if (IsHit(target.gameObject))
                {
                    if (ActiveHuman.CharData.type != UnitType.Support || !performSupportAbility)
                    {
                        ActiveHuman.Attack.Perform(target.gameObject, ActiveHuman.CharData, base.floatingTextMgr);
                        ActiveHuman.soundStatus = SoundStatus.Hit;
                    }
                    else if (ActiveHuman.CharData.type == UnitType.Support && performSupportAbility)
                    {
                        Debug.Log("Used ability");
                        ActiveHuman.Ability = new SuppressiveFire(SkillType.Single);

                        ActiveHuman.Ability.Perform(target.gameObject, ActiveHuman.CharData, base.floatingTextMgr);
                        ActiveHuman.soundStatus = SoundStatus.Ability;
                    }
                }
                else
                {
                    DisplayMissMsg(target.transform.position, colorPack.fontColor, colorPack.outlineColor);
                    ActiveHuman.soundStatus = SoundStatus.Miss;
                }

                HasAttacked = true;

                Debug.Log("Inside Enemy Controller Stuck at ability");
            }
            else
            {
                // Move if possible and hasn't already moved, otherwise
                AttemptMove(target.Position);
            }
        }
        else if (ActiveHuman.Attack.Type == SkillType.Multiple)
        {
            // is any player members close enough?
            // Get Position between player member
            // is within 140% of optimal range?
            // no? then move closer
            //ActiveHuman.soundStatus = SoundStatus.Ability;
        }

        NewDelay();
    }