Ejemplo n.º 1
0
    void PutAwayShield()
    {
        ShieldBehavior shield = transform.Find("Equipment").Find("ShieldSlot").GetChild(0).GetComponent <ShieldBehavior>();

        shield.PutAway();
        shield.GetComponent <Collider>().enabled = false;
    }
Ejemplo n.º 2
0
    void AttackMeleeRange()
    {
        transform.LookAt(shipTransform);

        RaycastHit[] hit = Physics.BoxCastAll(this.transform.position, new Vector3(1, 1, 1), Vector3.Normalize(-transform.position + shipTransform.position), Quaternion.identity, maxAttackDistance);

        for (int i = 0; i < hit.Length && i < maxTargets; i++)
        {
            if (hit[i].collider.GetComponent <ShieldBehavior>())
            {
                ShieldBehavior shield = hit[i].collider.GetComponent <ShieldBehavior>();
                shield.TakeDamage(status[level - 1].meleeDamage);
            }
            else if (hit[i].collider.GetComponent <ShipController>())
            {
                ShipController ship = hit[i].collider.GetComponent <ShipController>();
                ship.TakeDamage(status[level - 1].meleeDamage);
                HealthPanel.OnHealthChange?.Invoke(ship.GetCurrentHealth());
            }
        }

        currentMeleeAttackTime  = 0;
        currentMelleAttackDelay = 0;
        inAttack = false;
        Shoot(attackView);
    }
    void AttackMelle()
    {
        transform.LookAt(shipTransform);

        Ray ray = new Ray(this.gameObject.transform.position, Vector3.Normalize(-transform.position + shipTransform.position));

        RaycastHit[] hit = Physics.RaycastAll(ray, maxAttackDistance);

        for (int i = 0; i < hit.Length && i < maxTargets; i++)
        {
            if (hit[i].collider.GetComponent <ShieldBehavior>())
            {
                ShieldBehavior shield = hit[i].collider.GetComponent <ShieldBehavior>();
                shield.TakeDamage(status[level - 1].meleeDamage);
            }
            else if (hit[i].collider.GetComponent <ShipController>())
            {
                ShipController ship = hit[i].collider.GetComponent <ShipController>();
                ship.TakeDamage(status[level - 1].meleeDamage);
                HealthPanel.OnHealthChange?.Invoke(ship.GetCurrentHealth());
            }
        }

        currentMeleeAttackTime = 0;

        Shoot(attackView);
    }
Ejemplo n.º 4
0
    void DrawShield()
    {
        ShieldBehavior shield = transform.Find("Equipment").Find("ShieldSlot").GetChild(0).GetComponent <ShieldBehavior>();

        shield.DrawShield(transform);
        shield.GetComponent <Collider>().enabled = true;
    }
    private void OnEnable()
    {
        lives     = 3;
        bombCount = 1;
        damage    = 1;
        rof       = 1f;
        srt       = 60;

        bulletStockpile = GameObject.FindWithTag("GameController").GetComponent <BulletStockpile>();
        bulletStockpile.SetBps(0);
        rateOfFireText      = _rateOfFire.GetComponent <Text>();
        rateOfFireText.text = rof.ToString();
        damageText          = _damage.GetComponent <Text>();
        damageText.text     = damage.ToString();
        bombText            = _bombCounter.GetComponent <Text>();
        bombText.text       = bombCount.ToString();
        livesText           = _livesCounter.GetComponent <Text>();
        livesText.text      = lives.ToString();
        srtText             = _SRTCounter.GetComponent <Text>();
        srtText.text        = srt.ToString();

        shieldBehavior  = GetComponent <ShieldBehavior>();
        shipRender      = GetComponent <SpriteRenderer>();
        shipColl        = GetComponent <Collider2D>();
        soundController = GameObject.FindWithTag("GameController").GetComponent <SoundController>();
    }
Ejemplo n.º 6
0
    void CheckAllTargets()
    {
        if (currentTargets < 1)
        {
            currentTargets++;

            Collider[]        newTargets       = Physics.OverlapSphere(this.transform.position, radiusToDamage);
            List <GameObject> targetsAvaliable = new List <GameObject>();

            for (int i = 0; i < newTargets.Length; i++)
            {
                if (newTargets[i].GetComponent <ShieldBehavior>())
                {
                    ShieldBehavior shield = newTargets[i].GetComponent <ShieldBehavior>();
                    shield.TakeDamage(damage);
                }
                else if (newTargets[i].GetComponent <ShipController>())
                {
                    ShipController ship = newTargets[i].GetComponent <ShipController>();
                    ship.TakeDamage(damage);
                }
            }
        }

        Destroy(this.gameObject);
    }
Ejemplo n.º 7
0
    void FireShield()
    {
        ShieldBehavior shield = transform.Find("Equipment").Find("ShieldSlot").GetChild(0).GetComponent <ShieldBehavior>();

        stats.energy            -= shield.EnergyDrainAmount;
        stats.lastEnergyUsedTime = Time.time;
        shield.FireShield();
    }
Ejemplo n.º 8
0
 void OnParticleCollision(GameObject other)
 {
     if (other.GetComponent <ShieldBehavior>())
     {
         ShieldBehavior shield = other.GetComponent <ShieldBehavior>();
         shield.TakeDamage(damage);
     }
     else if (other.GetComponent <ShipController>())
     {
         ShipController ship = other.GetComponent <ShipController>();
         ship.TakeDamage(damage);
     }
 }
Ejemplo n.º 9
0
    new void Awake()
    {
        base.Awake();
        // Create a layer mask for the floor layer.
        floorMask       = LayerMask.GetMask("Floor");
        playerRigidbody = GetComponent <Rigidbody> ();
        if
        (waveletUi)
        {
            waveletUi.updateHealth();
        }

        shield = gameObject.GetComponentInChildren <ShieldBehavior>();
    }
 void OnParticleCollision(GameObject other)
 {
     if (other.GetComponent <ShieldBehavior>())
     {
         ShieldBehavior shield = other.GetComponent <ShieldBehavior>();
         shield.TakeDamage(damage);
     }
     else if (other.GetComponent <ShipController>())
     {
         ShipController ship = other.GetComponent <ShipController>();
         ship.TakeDamage(damage);
         HealthPanel.OnHealthChange?.Invoke(ship.GetCurrentHealth());
     }
 }
Ejemplo n.º 11
0
    private void TagetHit(RaycastHit2D hit, bool laser)
    {
        if (hit.collider != null)
        {
            Debug.Log(hit.collider.name);
            ShieldBehavior sh = hit.collider.gameObject.GetComponent <ShieldBehavior>();
            if (sh != null)
            {
                ScoresTxt.color = (Color.cyan + sh.GlobalLight.color) / 2;

                Combo.Variable.Value += 1;


                if (Combo.Variable.Value % ComboToLaser == 0)
                {
                    ComboTxt.gameObject.LeanScale(new Vector3(3, 3, 3), 0.2f).setOnComplete(Small);
                    qt.MoveInQTLaser();
                    MouseCoursor.Instance.UIImageClick = img2;
                    MouseCoursor.Instance.GetUIImageProps();
                }
                else
                {
                    ComboTxt.gameObject.LeanScale(new Vector3(2, 2, 2), 0.2f).setOnComplete(Small);
                }


                sh.ShBoom();
                Scores.Variable.Value += sh.points * 2;
                ScoresTxt.text         = Scores.Variable.Value.ToString();
                SoundMenager.Play(boom[Random.Range(0, boom.Length)], 0.6f);
            }
            else if (hit.collider.gameObject.GetComponent <SnailHandle>() != null)
            {
                SnailHandle snail = hit.collider.gameObject.GetComponent <SnailHandle>();
                snail.SnailBoom();
                SoundMenager.Play(slow, 0.5f);
                qt.MoveInQTSlow();
            }
        }
        else
        {
            if (!laser)
            {
                Combo.Variable.Value = 0;
            }
        }
    }
Ejemplo n.º 12
0
    private void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Enemy" || col.tag == "Player")
        {
            if (col.gameObject.tag != team)
            {
                Stats stats = col.gameObject.GetComponent <Stats>();

                if (stats.shielding == true)
                {
                    Transform      shield         = col.transform.Find("Equipment").Find("ShieldSlot").GetChild(0).transform;
                    ShieldBehavior shieldBehavior = shield.GetComponent <ShieldBehavior>();

                    bool shieldFacingBullet = ShieldDirection(col.transform.eulerAngles.y, transform.rotation.eulerAngles.y);

                    if (shieldFacingBullet == true)
                    {
                        damage -= shieldBehavior.baseDamageAbsorb;

                        if (shieldBehavior.damageType == damageType)
                        {
                            damage *= (shieldBehavior.damageAbsorbPercent * .01f);
                        }
                        else
                        {
                            damage *= ((shieldBehavior.damageAbsorbPercent / 2) * .01f);
                        }

                        knockback = knockback / 2;
                    }
                }

                stats.Damage(Mathf.Max(0, damage), damageType, transform.forward, col.gameObject);
                stats.GetComponent <Rigidbody>().AddForce(transform.forward * knockback, ForceMode.VelocityChange);
                durability--;
            }
        }
        else if (col.tag == "Destructible" || col.tag == "Effect" || col.gameObject.layer == LayerMask.NameToLayer("Environment"))
        {
            durability--;
        }

        else if (col.tag == "Shield")
        {
        }
    }
Ejemplo n.º 13
0
    IEnumerator _FireShield(int weaponNumber, string button)
    {
        //we're firing, dont fire again until we're done
        firing = true;
        Transform shield     = transform.Find("Equipment").Find("ShieldSlot").GetChild(0).transform;
        string    shieldType = shield.tag;

        ShieldBehavior shieldBehavior = shield.GetComponent <ShieldBehavior>();

        float _rotationSpeed = stats.rotationSpeed;
        float _movementSpeed = stats.movementSpeed;

        Vector4 weaponInfo = shieldBehavior.ShieldInfo();

        float fireSpeed         = weaponInfo.x;
        float chargeSpeed       = weaponInfo.y;
        float playerRotSlow     = weaponInfo.z;
        float energyDrainAmount = weaponInfo.w;

        Animate(Shielding_Animation);
        stats.rotationSpeed = stats.rotationSpeed - (stats.rotationSpeed * playerRotSlow / 100);
        stats.movementSpeed = stats.movementSpeed / 2;


        playerAnimator.SetFloat("FireSpeed", fireSpeed);
        playerAnimator.SetFloat("ChargeSpeed", chargeSpeed);

        float lastFireTime = 0;

        while ((Input.GetButton(button) && stats.energy - energyDrainAmount >= 0))
        {
            if (Time.time >= lastFireTime + (1 / fireSpeed) && charged == true)
            {
                playerAnimator.SetTrigger("Fire");
                lastFireTime = Time.time;
            }
            yield return(new WaitForFixedUpdate());
        }

        //set rotation speed to normal
        stats.rotationSpeed = _rotationSpeed;
        stats.movementSpeed = _movementSpeed;
        Animate(Idle_Animation);
        firing  = false;
        charged = false;
    }
Ejemplo n.º 14
0
    private void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Enemy" || col.tag == "Player")
        {
            if (col.gameObject.tag != team)
            {
                Stats stats   = col.gameObject.GetComponent <Stats>();
                float _damage = damage * Mathf.RoundToInt((Random.Range(.9f, 1.1f)) * 10) * .1f;

                if (stats.shielding == true)
                {
                    Transform      shield         = col.transform.Find("Equipment").Find("ShieldSlot").GetChild(0).transform;
                    ShieldBehavior shieldBehavior = shield.GetComponent <ShieldBehavior>();

                    bool shieldFacingBullet = ShieldDirection(col.transform.eulerAngles.y, transform.rotation.eulerAngles.y);

                    if (shieldFacingBullet == true)
                    {
                        _damage -= shieldBehavior.baseDamageAbsorb;

                        if (shieldBehavior.damageType == damageType)
                        {
                            _damage *= (shieldBehavior.damageAbsorbPercent * .01f);
                        }
                        else
                        {
                            _damage *= ((shieldBehavior.damageAbsorbPercent / 2) * .01f);
                        }

                        knockback = knockback / 2;
                    }
                }

                stats.Damage(Mathf.Max(0, _damage), damageType, transform.forward, col.gameObject);
                stats.GetComponent <Rigidbody>().AddForce(transform.forward * knockback, ForceMode.VelocityChange);
            }
        }
    }
Ejemplo n.º 15
0
 private void Start()
 {
     _player         = GameLogic.GetInstance().Player;
     _shieldBehavior = _player.GetShield();
     _levelManager   = GameLogic.GetInstance().Level;
 }