Esempio n. 1
0
    // Perform this attack on a single target
    public void Perform(GameObject target, CharacterData attackerData, FloatingTextManager floatingTxtMgr)
    {
        float dmgAmount = Formula.CalculateDamage(attackerData.attackPower);

        // Apply dmg to target
        if (target.tag == "Player" || target.tag == "Enemy" || target.tag == "Trap" || target.tag == "Collectable")
        {
            target.BroadcastMessage("ApplyDamage", dmgAmount);

            Vector3 textOffset = new Vector3(0, 30);
            floatingTxtMgr.CreateFloatingText(dmgAmount.ToString(), target.transform.position + textOffset, Color.red, Color.yellow);
            DmgEffectManager.CreateHit(target.transform.position);
        }
    }
Esempio n. 2
0
    // Perform this attack on multiple targets
    public void Perform(GameObject[] area, CharacterData attackerData, FloatingTextManager floatingTxtMgr)
    {
        foreach (GameObject t in area)
        {
            float dmgAmount = Formula.CalculateExplosiveDamage(t.transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition), attackerData.attackPower);
            if (t.tag == "Player" || t.tag == "Enemy" || t.tag == "Trap" || t.tag == "Collectable")
            {
                t.BroadcastMessage("ApplyDamage", dmgAmount);

                Vector3 textOffset = new Vector3(0, 30);
                floatingTxtMgr.CreateFloatingText(dmgAmount.ToString(), t.transform.position + textOffset, this.CategoryColor().fontColor, this.CategoryColor().outlineColor);
                DmgEffectManager.CreateHit(t.transform.position);
            }
        }
    }
Esempio n. 3
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. 4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "TrapDetonator")
        {
            Vector3 textOffset = new Vector3(0, 55, 0);

            other.transform.parent.gameObject.SendMessage("ApplyRecovery", recoveryAmount);
            BattleManager.GetFloatingTextManager.CreateFloatingText("+" + recoveryAmount.ToString() + " Recovery", other.transform.position + textOffset, Color.blue, Color.yellow);
            DmgEffectManager.CreateHit(other.transform.position);

            if (BattleManager.ActiveCharacter.tag == "Player")
            {
                BattleManager.GetPlayerController.CurrentTurnState = TurnState.ExitTurn;
            }
            else if (BattleManager.ActiveCharacter.tag == "Enemy")
            {
                BattleManager.GetEnemyController.HasAttacked = true;
            }

            Destroy(gameObject);
        }
    }