Пример #1
0
    public void EquipSword(string swordName)
    {
        if (HasSword)
        {
            DeequipSword();
        }

        Item       item   = _inventory.GetItem(swordName);
        GameObject prefab = item.weaponPrefab;

        GameObject g = Instantiate(prefab) as GameObject;

        g.name = prefab.name;

        Transform t = g.transform;

        t.SetParent(_playerController.WeaponContainerRight);
        t.localPosition = Vector3.zero;
        t.localRotation = Quaternion.identity;

        _sword = g.GetComponent <Weapon_Melee_Sword>();

        SwordProjectilesEnabled = IsAtFullHealth;
        SwordControlStyle       = Weapon_Base.ControlStyleEnum.Classic; // TODO
        _sword.CollisionIsAllowedWhenRetracted = false;                 // TODO
    }
Пример #2
0
 public void DeequipSword()
 {
     if (HasSword)
     {
         Destroy(_sword.gameObject);
         _sword = null;
     }
 }
Пример #3
0
    void OnHitWithSword(Weapon_Melee_Sword sword)
    {
        if (Visible)
        {
            return;
        }

        _swordHitsTaken++;

        UpdatePose();
        Appear();
    }
Пример #4
0
    void DamageTaken(HealthController healthController, ref uint damageAmount, GameObject damageDealer)
    {
        Weapon_Melee_Sword sword = damageDealer.GetComponent <Weapon_Melee_Sword>();
        bool wasHitBySword       = (sword != null);

        bool wasHitBySilverArrow = damageDealer.name.Contains("SilverArrow_Projectile");


        EnemyAI_Zol zol = GetComponent <EnemyAI_Zol>();

        if (zol != null)
        {
            if (damageAmount == 1)
            {
                zol.SpawnGels();
                healthController.Kill(damageDealer, true);
            }
        }

        EnemyAI_Dodongo dodongo = GetComponent <EnemyAI_Dodongo>();

        if (dodongo != null)
        {
            // Player can one-hit kill Dodongo when it stunned after eating a bomb
            if (dodongo.StunnedByBomb)
            {
                healthController.Kill(damageDealer, true);
            }
            else
            {
                damageAmount = 0;
                PlayShieldSound();
            }
        }

        EnemyAI_Gohma gohma = GetComponent <EnemyAI_Gohma>();

        if (gohma != null)
        {
            if (gohma.IsEyeClosed)
            {
                damageAmount = 0;
                PlayShieldSound();
            }
        }

        EnemyAI_Gannon gannon = GetComponent <EnemyAI_Gannon>();

        if (gannon != null)
        {
            if (wasHitBySword)
            {
                ZeldaHaptics.Instance.RumbleSimple_Right();
                SendMessage("OnHitWithSword", sword, SendMessageOptions.RequireReceiver);
            }
            else if (wasHitBySilverArrow)
            {
                ZeldaHaptics.Instance.RumbleSimple_Left();
                SendMessage("OnHitWithSilverArrow", SendMessageOptions.RequireReceiver);
            }

            damageAmount = 0;
        }

        if (damageAmount > 0)
        {
            if (GetComponent <Enemy>().pushBackOnhit)
            {
                if (DoesWeaponApplyPushbackForce(damageDealer))
                {
                    Vector3 direction = transform.position - damageDealer.transform.position;
                    direction.y = 0;
                    direction.Normalize();

                    Vector3 force = direction * PUSH_BACK_POWER;
                    GetComponent <Enemy>().Push(force);
                }
            }

            if (wasHitBySword)
            {
                ZeldaHaptics.Instance.RumbleSimple_Right();
            }
        }
    }