Пример #1
0
    IEnumerator Start()
    {
        if (thisPlayer != null && thisPlayer.character is M*******t)
        {
            thisMasochist = thisPlayer.character as M*******t;
        }
        thisCollider    = GetComponent <SphereCollider>();
        shieldSprite    = GetComponentInChildren <SpriteRenderer>();
        absorbedBullets = new List <PhysicsObj>();

        float timeElapsed = 0;

        while (timeElapsed < shieldDuration)
        {
            timeElapsed += Time.deltaTime;

            if (thisPlayer.durationBar != null)
            {
                thisPlayer.durationBar.SetPercent(1 - timeElapsed / shieldDuration);
            }

            yield return(null);
        }
        if (thisPlayer.durationBar != null)
        {
            thisPlayer.durationBar.SetPercent(0);
        }
    }
Пример #2
0
    //TODO: Move the ship-specific logic to Ship subclasses and common logic to Ship base class
    protected virtual void OnTriggerEnter(Collider other)
    {
        //Destroy bullets upon hitting a killzone
        if (other.tag == "KillZone")
        {
            curState = BulletState.none;
            DestroyThisBullet();
        }
        //Deal damage to any other player hit
        else if (other.tag == "Player")
        {
            Ship      shipHit      = other.gameObject.GetComponentInParent <Ship>();
            Character characterHit = shipHit.character;

            if (characterHit.playerEnum != owningPlayer)
            {
                //Masochists with the shield up are immune to incoming bullets
                if (characterHit.characterType == CharactersEnum.m*******t)
                {
                    M*******t masochistHit = characterHit as M*******t;
                    if (masochistHit != null && masochistHit.masochistShip.shieldUp)
                    {
                        return;
                    }
                }

                //TODO: Re-add m*******t damage multiplier to bullet creation
                //Do damage to the player hit
                shipHit.TakeDamage(damage);

                GameObject explosion = Instantiate(explosionPrefab, other.gameObject.transform.position, new Quaternion()) as GameObject;
                Destroy(explosion, 5f);
                curState = BulletState.none;
                DestroyThisBullet();
            }
            //TODO: What the heck? Why is this thisPlayer == vampire? We should re-write this
            //If the bullet was absorbed by the vampire with it's shield up, heal slightly instead of doing damage
            else if (owningPlayer != PlayerEnum.none && thisPlayer.character.characterType == CharactersEnum.vampire)
            {
                if (curState == BulletState.absorbedByVampire)
                {
                    shipHit.TakeDamage(damage * -vampShieldHealAmount);
                    curState = BulletState.none;
                    damage   = 1;
                    DestroyThisBullet();
                }
            }
        }
        //Deal damage to any ProtagShip hit
        else if (other.tag == "ProtagShip")
        {
            DamageableObject otherShip = other.gameObject.GetComponentInParent <DamageableObject>();
            otherShip.TakeDamage(damage);

            GameObject explosion = Instantiate(explosionPrefab, other.gameObject.transform.position, new Quaternion()) as GameObject;
            Destroy(explosion, 5f);
            curState = BulletState.none;
            DestroyThisBullet();
        }
    }
Пример #3
0
    public void FireBurst()
    {
        if (GameManager.S.inGame)
        {
            SoundManager.instance.Play("Explosion");
        }
        explosionParticles = transform.GetChild(0).GetChild(0).GetComponent <ParticleSystem>();

        //Scale the explosion size based on the damage multiplier
        M*******t masochistPlayer = GameManager.S.players[(int)owningPlayer].character as M*******t;

        if (masochistPlayer != null)
        {
            explosionRadius = explosionRadius * masochistPlayer.masochistShip.damageMultiplier;
            explosionParticles.startSize = explosionParticles.startSize * masochistPlayer.masochistShip.damageMultiplier;
        }

        Collider[] hitTargets = Physics.OverlapSphere(transform.position, explosionRadius);

        foreach (Collider target in hitTargets)
        {
            DamageTarget(target);
        }

        //Destroy after an arbitrary amount of time (explosion will be finished quick, this is just clean-up)
        Destroy(gameObject, 2f);
    }
Пример #4
0
    //Damage any player or protag ship that is within the explosion
    void DamageTarget(Collider other)
    {
        if (other.tag == "Player")
        {
            Ship shipHit = other.gameObject.GetComponentInParent <Ship>();
            //Do damage to the player hit
            float     multiplier      = 1f;
            M*******t masochistPlayer = GameManager.S.players[(int)owningPlayer].character as M*******t;
            if (masochistPlayer != null)
            {
                multiplier = masochistPlayer.masochistShip.damageMultiplier;
            }
            damageDealt = CalculateDamageDealt(other.transform) * multiplier;
            shipHit.TakeDamage(damageDealt);
            //print("Damage Dealt: " + damageDealt);

            GameObject explosion = Instantiate(explosionPrefab, other.gameObject.transform.position, new Quaternion()) as GameObject;
            Destroy(explosion, 5f);
        }
        else if (other.tag == "ProtagShip")
        {
            DamageableObject otherShip       = other.gameObject.GetComponentInParent <DamageableObject>();
            M*******t        masochistPlayer = GameManager.S.players[(int)owningPlayer].character as M*******t;
            if (masochistPlayer != null)
            {
                damageDealt = CalculateDamageDealt(other.transform) * masochistPlayer.masochistShip.damageMultiplier;
            }
            else
            {
                damageDealt = CalculateDamageDealt(other.transform);
            }
            otherShip.TakeDamage(damageDealt);

            GameObject explosion = Instantiate(explosionPrefab, other.gameObject.transform.position, new Quaternion()) as GameObject;
            Destroy(explosion, 5f);
        }
    }