Пример #1
0
    IEnumerator DeathCoroutine(AttackStats attackStats)
    {
        while (!m_CharacterController.isGrounded || m_LaunchDirection != LaunchDirection.NO_LAUNCH)
        {
            yield return(null);
        }

        m_CharacterController.enabled = false;

        m_EnemyManager.ReportEnemyDeath(this, attackStats.damageProvider, m_Data.VitaeDropQuantity);

        yield return(new WaitForSeconds(m_DelayToDestroy));

        FXDeath = Instantiate(m_FXDeath);

        if (IsLookingRight)
        {
            FXDeath.transform.position = new Vector3(transform.position.x + 1.0f, transform.position.y - 1.0f, transform.position.z);
        }

        else if (!IsLookingRight)
        {
            FXDeath.transform.position = new Vector3(transform.position.x - 1.0f, transform.position.y - 1.0f, transform.position.z);
        }

        FXDeath.Play(true);
        Destroy(gameObject);
        Destroy(attack1);
    }
Пример #2
0
    //public void CollectVitae(int amount)
    //{
    //    m_Vitae += amount;

    //    if (OnVitaeChange != null)
    //        OnVitaeChange(m_Vitae);
    //}

    public override void TakeDamage(AttackStats attackStats)
    {
        if (!m_Invincible)
        {
            base.TakeDamage(attackStats);

            if (OnTakeDamage != null)
            {
                OnTakeDamage();
            }

            m_Animator.SetInteger("HP", m_HP);
            m_Animator.SetBool("IsStun", true);

            StartCoroutine(visualFeedback.ApplyChange());

            if (m_HP > 0)
            {
                m_Invincible = true;
                StartCoroutine(InvincibilityFrames());
            }
            else if (m_DeathCoroutine == null)
            {
                m_PlayerManager.ReportPlayerDeath();
                m_DeathCoroutine = StartCoroutine(DeathCoroutine());
            }
        }
    }
Пример #3
0
 void OnTargetBeginCastingAttack(AttackStats attack)
 {
     if (Time.time > lastDodgeTime + dodgeCooldown.Value && DistFromTarget <= dodgeDetectRadius.Value && Random.Range(0, 100f) > dodgeChances)
     {
         Invoke("Dodge", dodgeWaitTime.Value);
     }
 }
Пример #4
0
    IEnumerator HandlePickUp(AttackStats attack)
    {
        var colliders = Physics.OverlapSphere(transform.position, pickUpRadius);

        Collider to_pickUpObejct = null;

        foreach (var collider in colliders)
        {
            if (collider.gameObject.tag == TagsTypeString.Pickable.ToString())
            {
                to_pickUpObejct = collider;
                break;
            }
        }
        if (to_pickUpObejct == null)
        {
            yield return(0);
        }
        pickedUpObject = to_pickUpObejct.gameObject;
        pickedUpObject.GetComponent <BoxCollider>().isTrigger = true;
        pickedUpObject.GetComponent <Rigidbody>().isKinematic = true;
        pickedUpObject.tag = gameObject.tag;

        yield return(new WaitForSeconds(0.9f));

        pickedUpObject.transform.parent        = animator.GetBoneTransform(HumanBodyBones.RightHand);
        pickedUpObject.transform.localPosition = new Vector3(0, 0, 0);
    }
Пример #5
0
    IEnumerator ShootRoutine()
    {
        AttackStats aStats = new AttackStats();

        aStats.damageMin = damage;
        aStats.damageMax = damage;

        for (int i = 0; i < rounds; i++)
        {
            yield return(new WaitForSeconds(shotDelay));

            for (int n = 0; n < spinObject.childCount; n++)
            {
                Transform sp = spinObject.GetChild(n);

                UnitPlayer     player      = GameControl.GetPlayer();
                AttackInstance attInstance = new AttackInstance(player, aStats);

                GameObject soObj = (GameObject)Instantiate(shootObject, sp.position, sp.rotation);
                soObj.GetComponent <ShootObject>().Shoot(player.thisObj.layer, range, sp, attInstance);
            }
        }

        yield return(null);

        Destroy(gameObject);
    }
Пример #6
0
 public void ReportAttack(Entity owner, Entity target, AttackStats attackStats)
 {
     if (OnDamage != null && owner != null && target != null)
     {
         OnDamage(owner, target, attackStats);
     }
 }
Пример #7
0
    public Warrior() : base()
    {
        _myName      = "Landorin";
        _myClassName = "Warrior";
        _mySprite    = Resources.Load <Sprite>("UI/CharacterInfo/Sprites/" + _myClassName);

        _myHealth    = 200;
        _myMaxHealth = _myHealth;

        _myMana    = 100;
        _myMaxMana = _myMana;

        _myOffense  = new AttackStats(20, 0, 75, 20);
        _myDefenses = new DefenseStats(5, 10, -5, -5, -5, -5, -5);

        _myWeapon = new Axe();

        _myAbilites.Add(new DoubleSlash());

        _mySpeed      = Random.Range(5, 50);
        _myMovement   = 2;
        _currMovement = _myMovement;
        _gridPos      = Vector2.zero;
        _dead         = false;
    }
Пример #8
0
    public override AttackStats GetCurrentAttack()
    {
        AttackStats stats = base.GetCurrentAttack();

        if (m_PowerUpsLevels.CrowdControl > 0 && m_CurrentAttack == "LightAttack1")
        {
            stats.launchDirection = LaunchDirection.MOVE;
            stats.axis            = AttackStats.Axis.Z;
        }

        if (m_PowerUpsLevels.LightAttack > 0 && (m_CurrentAttack == "LightAttack1" || m_CurrentAttack == "LightAttack2" || m_CurrentAttack == "LightAttack3"))
        {
            float rate = m_PowerUpsData.LightAttack.GetMeleeValue(m_PowerUpsLevels.LightAttack) / 100f;

            stats.damage *= (int)(1f + rate);
        }

        if (m_PowerUpsLevels.AirAttack > 0 && (m_CurrentAttack == "AirAttack" || m_CurrentAttack == "AirKnockdown"))
        {
            float rate = m_PowerUpsData.AirAttack.GetMeleeValue(m_PowerUpsLevels.LightAttack) / 100f;

            stats.damage *= (int)(1f + rate);
        }

        return(stats);
    }
Пример #9
0
    void SetKnockback(AttackStats stats)
    {
        m_LaunchDirection = stats.launchDirection;
        m_HorizontalDir   = stats.horizontalDir;

        m_CurrentKnockTime   = 0f;
        m_KnockStartPosition = transform.localPosition;

        if (m_LaunchDirection == LaunchDirection.MOVE)
        {
            m_PushTargetPosition = transform.position;

            switch (stats.axis)
            {
            case AttackStats.Axis.X:
            {
                m_PushTargetPosition.x = stats.targetPosition;
                break;
            }

            case AttackStats.Axis.Z:
            {
                m_PushTargetPosition.z = stats.targetPosition;
                break;
            }

            default: break;
            }
        }
    }
Пример #10
0
    public void OnPlayerDamage(Entity owner, Entity target, AttackStats attackStats)
    {
        int targetLayer = target.gameObject.layer;

        if (targetLayer == LayerMask.NameToLayer("PlayerHitBox") && !m_Invincible)
        {
            target.TakeDamage(attackStats);

            //CheckDeath();
        }
        else if (targetLayer == LayerMask.NameToLayer("EnemyHitBox") || targetLayer == LayerMask.NameToLayer("BrickHitbox"))
        {
            Player player = (Player)owner;

            if (targetLayer == LayerMask.NameToLayer("EnemyHitBox"))
            {
                AddFusionScore(m_Vitae / m_GameSettings.FusionHitRatio);
            }

            if (attackStats.type == AttackType.LIGHT)
            {
                player.OnLightAttackHit(target);
            }
            else
            {
                player.OnHeavyAttackHit(target);
            }
        }
    }
Пример #11
0
 void OnEnemyDamage(Entity owner, Entity target, AttackStats stats)
 {
     if (target.gameObject.layer == LayerMask.NameToLayer("EnemyHitBox"))
     {
         target.TakeDamage(stats);
     }
 }
Пример #12
0
    public override void TakeDamage(AttackStats attackStats)
    {
        base.TakeDamage(attackStats);

        if (attackStats.launchDirection != LaunchDirection.NO_LAUNCH)
        {
            UnsetAttack();
        }

        SetKnockback(attackStats);
        StartCoroutine(TakeDammageFeedBack());

        StartCoroutine(visualFeedback.ApplyChange());

        if (m_HP == 0 && m_IsAlive)
        {
            m_IsAlive = false;
            StartCoroutine(DeathCoroutine(attackStats));

            if (OnDeath != null)
            {
                OnDeath();
            }
        }
    }
Пример #13
0
    IEnumerator attackDelay(AttackStats attack)
    {
        canAttack = false;
        canMove   = false;
        damage    = attack.attDam;
        if (attack.hitBox1 != null)
        {
            attack.hitBox1.SetActive(true);
        }
        if (attack.hitBox2 != null)
        {
            attack.hitBox2.SetActive(true);
        }
        yield return(new WaitForSeconds(anim.GetCurrentAnimatorClipInfo(0).Length));

        if (attack.hitBox1 != null)
        {
            attack.hitBox1.SetActive(false);
        }
        if (attack.hitBox2 != null)
        {
            attack.hitBox2.SetActive(false);
        }
        damage    = 0;
        canAttack = true;
        canMove   = true;
    }
Пример #14
0
 public void Hit(AttackStats stats)
 {
     health -= stats.damage;
     if (health < 0)
     {
         EnemyControllerScript.Instance.DestroyEnemy(this);
         return;
     }
     if (stats.damageDuration > 0)
     {
         if (damageOverTimeEffects.ContainsKey(stats.source))
         {
             damageOverTimeEffects[stats.source].duration = stats.damageDuration;
             damageOverTimeEffects[stats.source].value    = stats.damagePerSecond;
         }
         else
         {
             damageOverTimeEffects.Add(stats.source, new Effect(stats.damageDuration, stats.damagePerSecond));
         }
     }
     if (stats.slowDuration > 0)
     {
         if (slowEffects.ContainsKey(stats.source))
         {
             slowEffects[stats.source].duration = stats.slowDuration;
             slowEffects[stats.source].value    = stats.slow;
         }
         else
         {
             slowEffects.Add(stats.source, new Effect(stats.slowDuration, stats.slow));
         }
     }
 }
Пример #15
0
 private void Start()
 {
     m_AttackStats = new AttackStats
     {
         damage = Damages,
         name   = "Thorns"
     };
 }
Пример #16
0
    void OnEnable()
    {
        attackStats  = GetComponent <AttackStats>();
        goToUnitTask = GetComponent <GoToUnitTask>();
        Damageable damageable = GetComponent <Damageable>();

        damageable.ReceivedDamage += new Damageable.ReceiveDamageEventHandler(OnReceivedDamage);
    }
Пример #17
0
 public FireDotDebuff(AttackStats sourceStats, float damagePerTick, float timeBetweenTicks, float maxDuration)
 {
     harmful               = true;
     this.sourceStats      = sourceStats;
     this.damagePerTick    = damagePerTick;
     this.timeBetweenTicks = timeBetweenTicks;
     this.maxDuration      = maxDuration;
     duration              = 0;
 }
Пример #18
0
 public void ReceiveDamage(float force, AttackStats attackStats)
 {
     if (ReceivedDamage != null)
     {
         Unit attackingUnit = attackStats.GetComponentInParent <Unit>();
         ReceivedDamage(attackingUnit);
     }
     Life -= force * attackStats.Strength - Defence;
 }
Пример #19
0
    public void TakeDamage(AttackStats attackStats)
    {
        if (!m_IsAlive)
        {
            return;
        }

        Death();
    }
Пример #20
0
    private void OnTriggerEnter(Collider other)
    {
        AttackStats stats = m_Owner.GetCurrentAttack();

        if (stats == null)
        {
            return;
        }

        m_Owner.QuickFreeze();

        Vector3 direction = Vector3.zero;

        direction.x         = other.transform.position.x - transform.position.x;
        direction           = direction.normalized;
        stats.horizontalDir = direction.x;

        stats.damageProvider = m_Owner;

        if (stats.launchDirection == LaunchDirection.MOVE)
        {
            switch (stats.axis)
            {
            case AttackStats.Axis.X:
            {
                Vector3 extents = m_BoxCollider.bounds.extents;
                stats.targetPosition = transform.TransformPoint(m_BoxCollider.center).x + extents.x * direction.x;
                break;
            }

            case AttackStats.Axis.Z:
            {
                stats.targetPosition = transform.position.z;
                break;
            }

            default: break;
            }
        }

        if (other.gameObject.layer != LayerMask.NameToLayer("BrickHitbox"))
        {
            m_BattleManager.ReportAttack(m_Owner, other.GetComponent <Entity>(), stats);
        }
        else
        {
            IDamageable temp = other.gameObject.GetComponent <IDamageable>();
            if (temp != null)
            {
                temp.TakeDamage(stats);
            }

            m_BattleManager.ReportBrickAttack(m_Owner, other.transform.position);
        }
        //m_BattleManager.ReportBrickDestruction(other.GetComponent<IDamageable>(), stats);
    }
Пример #21
0
    public override void TakeDamage(AttackStats attackStats)
    {
        base.TakeDamage(attackStats);
        m_ComboCount = 0;

        if (OnComboChange != null)
        {
            OnComboChange(m_ComboCount);
        }
    }
Пример #22
0
        public static StatsList CreateStatsListWithDefaultValues()
        {
            AttackStats  attackStats  = new AttackStats(0, 0, 0, 0, 0);
            DefenceStats defenceStats = new DefenceStats(0, 0, 0, 0, 0);
            BodyStats    body         = new BodyStats(0, 0);
            CritStats    crit         = new CritStats(0, 0);
            StatsList    stats        = new StatsList(attackStats, defenceStats, body, crit);

            return(stats);
        }
Пример #23
0
 public void TakeDamage(AttackStats attackStats)
 {
     if (!m_IsOpen)
     {
         if (m_Life-- == 0)
         {
             m_IsOpen = true;
             Destroy(gameObject); // temp
         }
     }
 }
Пример #24
0
 public static IEnumerable <KeyValuePair <string, string> > GetPanelContent(AttackStats baseStats, AttackStats fullStats, bool alwaysShowSign = false)
 {
     return(new KeyValuePair <string, string>[]
     {
         new KeyValuePair <string, string>("Max Health", GetStatText(baseStats.MaxHealth, fullStats.MaxHealth, alwaysShowSign)),
         new KeyValuePair <string, string>("Attack", GetStatText(baseStats.DamageDealt, fullStats.DamageDealt, alwaysShowSign)),
         new KeyValuePair <string, string>("Defence", GetStatText(baseStats.DamageReduction, fullStats.DamageReduction, alwaysShowSign)),
         new KeyValuePair <string, string>("Accuracy", GetStatText(baseStats.Accuracy * 100, fullStats.Accuracy * 100, alwaysShowSign) + "%"),
         new KeyValuePair <string, string>("Speed", GetStatText(baseStats.Accuracy * 100, fullStats.Accuracy * 100, alwaysShowSign)),
     });
 }
Пример #25
0
    public AttackStats GenerateRandomFromSelf()
    {
        AttackStats output = new AttackStats();

        output.MaxHealth       = Random.Range(-MaxHealth, MaxHealth);
        output.DamageDealt     = Random.Range(-DamageDealt, DamageDealt);
        output.DamageReduction = Random.Range(-DamageReduction, DamageReduction);
        output.Accuracy        = Random.Range(-Accuracy, Accuracy);
        output.Speed           = Random.Range(-Speed, Speed);
        return(output);
    }
Пример #26
0
    public AttackStats Merge(AttackStats other)
    {
        AttackStats output = new AttackStats();

        output.MaxHealth       = MaxHealth + other.MaxHealth;
        output.DamageDealt     = DamageDealt + other.DamageDealt;
        output.DamageReduction = DamageReduction + other.DamageReduction;
        output.Accuracy        = Accuracy + other.Accuracy;
        output.Speed           = Speed + other.Speed;
        return(output);
    }
Пример #27
0
    public AttackStats Scale(float scale)
    {
        AttackStats output = new AttackStats();

        output.MaxHealth       = Mathf.RoundToInt(MaxHealth * scale);
        output.DamageDealt     = Mathf.RoundToInt(DamageDealt * scale);
        output.DamageReduction = Mathf.RoundToInt(DamageReduction * scale);
        output.Accuracy        = Mathf.RoundToInt(Accuracy * scale);
        output.Speed           = Mathf.RoundToInt(Speed * scale);
        return(output);
    }
Пример #28
0
    void SetUpAttacks()
    {
        foreach (var attackObject in characterStats.attacks)
        {
            var attack = attackObject.GetComponent <AttackStats>();
            switch (attack.attackType)
            {
            case AttackType.None:
            {
                continue;
            }

            case AttackType.PowerUp:
            {
                PowerUp = attack; continue;
            }

            case AttackType.PickUp:
            {
                PickUp = attack; continue;
            }

            case AttackType.Throw:
            {
                Throw = attack; continue;
            }

            case AttackType.Super1:
            {
                SuperAttacks.Add(attack); continue;
            }

            case AttackType.Super2:
            {
                SuperAttacks.Add(attack); continue;
            }

            case AttackType.Super3:
            {
                SuperAttacks.Add(attack); continue;
            }

            case AttackType.Super4:
            {
                SuperAttacks.Add(attack); continue;
            }

            default:
            {
                NormalAttacks.Add(attack); continue;
            }
            }
        }
    }
Пример #29
0
    public void Initialize(AttackType type, AttackStats stats)
    {
        m_pAttackStats = Instantiate(stats) as AttackStats;
        m_pAttackStats.transform.parent = this.transform;
        m_pAttackStats.gameObject.layer = this.gameObject.layer;

        m_pAttackType = Instantiate(type) as AttackType;
        m_pAttackType.transform.parent = this.transform;
        m_pAttackType.gameObject.layer = this.gameObject.layer;
        m_pAttackType.Initialize(this);
    }
Пример #30
0
 public AttackStats(AttackStats source)
 {
     name            = source.name;
     damageProvider  = source.damageProvider;
     type            = source.type;
     launchDirection = source.launchDirection;
     axis            = source.axis;
     horizontalDir   = source.horizontalDir;
     targetPosition  = source.targetPosition;
     damage          = source.damage;
     stunDuration    = source.stunDuration;
 }
Пример #31
0
    public virtual void SetAttack(string name)
    {
        AttackStats attack = GetAttackStats(name);

        if (attack == null)
        {
            Debug.LogError("The attack \"" + name + "\" does not exist. Did you mispell it somewhere ?");
            return;
        }

        m_CurrentAttack = name;
    }
Пример #32
0
    public static Attack CreateAttack(AttackType type, AttackStats stats, Vector3 pos, GameObject parent)
    {
        GameObject go = new GameObject();
        go.AddComponent<Attack>();
        go.transform.parent = parent.transform;
        go.layer = parent.layer;
        go.name = "Attack";

        Attack attack = go.GetComponent<Attack>();
        attack.Initialize(type, stats);

        go.transform.position = pos;

        return attack;
    }