Esempio n. 1
0
    void OnTriggerStay2D(Collider2D other)
    {
        // Interacting with your base
        if (other.gameObject.CompareTag("Demon Base") && gameObject.tag == "Demon")
        {
            if (hasFlag && canCapture)
            {
                #region TriggerStay Variable Changes
                canFire  = true;
                canMelee = true;
                Invoke("ResetFires", 0.5f);
                AngelFlag.transform.position = AngelBase.transform.position;
                AngelFlag.GetComponent <FlagScript>().inBase = true;
                hasFlag   = false;
                canFire   = true;
                canShield = true;
                canMelee  = true;
                UI.GetComponent <CTFUIScript>().demonScore++;
                canCapture = false;
                Invoke("CanCapture", 1f);
                GameObject.Find("Main Camera").GetComponent <CameraScript>().shakeDuration = .75f;
                Invoke("StopShake", 1f);
                GameObject score = (Instantiate(scoreParticles[1], new Vector3(DemonBase.transform.position.x, DemonBase.transform.position.y), mainCamera.transform.rotation)) as GameObject;
                Destroy(score, 2f);
                #endregion
            }
        }

        // If you bring the enemy team's flag to your base, do this vvv
        if (other.gameObject.CompareTag("Angel Base") && gameObject.tag == "Angel")
        {
            if (hasFlag && canCapture)
            {
                #region TriggerStay Variable Changes
                canFire  = true;
                canMelee = true;
                Invoke("ResetFires", 0.5f);
                Invoke("CanCapture", 1f);
                DemonFlag.transform.position = DemonBase.transform.position;
                DemonFlag.GetComponent <FlagScript>().inBase = true;
                hasFlag   = false;
                canFire   = true;
                canShield = true;
                canMelee  = true;
                UI.GetComponent <CTFUIScript>().angelScore++;
                canCapture = false;
                GameObject.Find("Main Camera").GetComponent <CameraScript>().shakeDuration = .75f;
                Invoke("StopShake", 1f);
                GameObject score = (Instantiate(scoreParticles[0], new Vector3(AngelBase.transform.position.x, AngelBase.transform.position.y), mainCamera.transform.rotation)) as GameObject;
                Destroy(score, 2f);
                #endregion
            }
        }
    }
Esempio n. 2
0
 // Ending the flag throw
 public void EndFlagThrow()
 {
     if (this.gameObject.CompareTag("Angel"))
     {
         DemonFlag.GetComponent <FlagScript>().beingThrown = false;
         DemonFlag.GetComponent <FlagScript>().throwSpeed /= 2;
         DemonFlag.GetComponent <FlagScript>().onPlayer    = false;
     }
     else if (this.gameObject.CompareTag("Demon"))
     {
         AngelFlag.GetComponent <FlagScript>().beingThrown = false;
         AngelFlag.GetComponent <FlagScript>().throwSpeed /= 2;
         DemonFlag.GetComponent <FlagScript>().onPlayer    = false;
     }
 }
Esempio n. 3
0
 // Trigger exit function
 private void OnTriggerExit2D(Collider2D other)
 {
     // How you interact with flags will differe depending on your player type.
     if (this.gameObject.CompareTag("Angel"))
     {
         if (other.gameObject.CompareTag("Angel Flag"))
         {
             if (AngelFlag.GetComponent <FlagScript>().inBase == true)
             {
                 // Flag is in base, nothing needs to happen.
             }
             else if (AngelFlag.GetComponent <FlagScript>().inBase == false)
             {
                 // Flag is not in base, begin returning.
             }
         }
         else if (other.gameObject.CompareTag("Demon Flag"))
         {
             // Don't have the enemy team's flag anymore.
             hasFlag = false;
         }
     }
     else if (this.gameObject.CompareTag("Demon"))
     {
         if (other.gameObject.CompareTag("Angel Flag"))
         {
             // Don't have the enemy team's flag anymore.
             hasFlag = false;
         }
         else if (other.gameObject.CompareTag("Demon Flag"))
         {
             if (DemonFlag.GetComponent <FlagScript>().inBase == true)
             {
                 // Flag is in base, nothing needs to happen.
             }
             else if (DemonFlag.GetComponent <FlagScript>().inBase == false)
             {
                 // Flag is not in base, begin returning.
             }
         }
     }
 }
Esempio n. 4
0
    // Sets all references and assigns characters
    #endregion

    void Awake()
    {
        #region Initialized Variables
        if (this.gameObject.name == "Urial(Clone)")
        {
            this.gameObject.name = "Urial";
        }
        else if (this.gameObject.name == "Barachial(Clone)")
        {
            this.gameObject.name = "Barachial";
        }
        else if (this.gameObject.name == "Lilith(Clone)")
        {
            this.gameObject.name = "Lilith";
        }
        else if (this.gameObject.name == "Azazel(Clone)")
        {
            this.gameObject.name = "Azazel";
        }
        // Grab the character master and sprite for assignment to the player.
        rb = GetComponent <Rigidbody2D>();
        // Set all bools to proper state
        dead          = false;
        invincible    = false;
        FlagReference = DemonFlag.GetComponent <FlagScript>();
        invincibleShield.SetActive(false);
        canFire        = true;
        canShield      = true;
        stunIconShow   = true;
        hasFlag        = false;
        stunned        = false;
        stunIconToggle = true;
        canMelee       = true;
        meleeing       = false;
        shieldPowerUp  = false;
        canThrowFlag   = true;
        canCapture     = true;
        invincAnim     = invincibleShield.GetComponent <Animator>();
        animator       = GetComponent <Animator>();
        #endregion
    }
Esempio n. 5
0
 // Death Function
 public void Die()
 {
     // if youre not invincible then die and do all this stuff
     if (!invincible)
     {
         #region Death Variable Changes/data kept track
         hasFlag = false;
         if (this.gameObject.name == "Urial")
         {
             GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().urialAlive = false;
         }
         else if (this.gameObject.name == "Barachial")
         {
             GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().barachialAlive = false;
         }
         else if (this.gameObject.name == "Lilith")
         {
             GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().lilithAlive = false;
         }
         else if (this.gameObject.name == "Azazel")
         {
             GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().azazelAlive = false;
         }
         rb.velocity = new Vector2(0f, 0f);
         gameObject.SetActive(false);
         meleeing = false;
         dead     = true;
         stunned  = false;
         if (gameObject.CompareTag("Demon"))
         {
             GameObject death = (Instantiate(deathParticleD, new Vector3(transform.position.x, transform.position.y), mainCamera.transform.rotation)) as GameObject;
             Destroy(death, 2f);
             DemonFlag.GetComponent <FlagScript>().beingReturned = false;
         }
         else if (gameObject.CompareTag("Angel"))
         {
             GameObject death = (Instantiate(deathParticleA, new Vector3(transform.position.x, transform.position.y), mainCamera.transform.rotation)) as GameObject;
             Destroy(death, 2f);
             AngelFlag.GetComponent <FlagScript>().beingReturned = false;
         }
         // new respawning
         if (this.gameObject.CompareTag("Demon"))
         {
             if (!DemonFlag.GetComponent <FlagScript>().inBase)
             {
                 if (DemonFlag.transform.position.y > 0)
                 {
                     respawnRandomizer = Random.Range(0, 2);
                     if (this.gameObject.name == "Azazel")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation1;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation3;
                         }
                     }
                     else if (this.gameObject.name == "Lilith")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation2;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation4;
                         }
                     }
                 }
                 else if (DemonFlag.transform.position.y <= 0)
                 {
                     respawnRandomizer = Random.Range(0, 2);
                     if (this.gameObject.name == "Azazel")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation2;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation4;
                         }
                     }
                     else if (this.gameObject.name == "Lilith")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation1;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation3;
                         }
                     }
                 }
             }
             else if (DemonFlag.GetComponent <FlagScript>().inBase)
             {
                 respawnRandomizer = Random.Range(0, 4);
                 if (respawnRandomizer == 0)
                 {
                     transform.position = SpawnLocation1;
                 }
                 else if (respawnRandomizer == 1)
                 {
                     transform.position = SpawnLocation2;
                 }
                 else if (respawnRandomizer == 2)
                 {
                     transform.position = SpawnLocation3;
                 }
                 else if (respawnRandomizer == 3)
                 {
                     transform.position = SpawnLocation4;
                 }
             }
             if (this.gameObject.name == "Azazel")
             {
                 Instantiate(azazelRespawnIndicator, this.gameObject.transform.position, Quaternion.identity);
             }
             else if (this.gameObject.name == "Lilith")
             {
                 Instantiate(lilithRespawnIndicator, this.gameObject.transform.position, Quaternion.identity);
             }
         }
         else if (this.gameObject.CompareTag("Angel"))
         {
             if (!AngelFlag.GetComponent <FlagScript>().inBase)
             {
                 if (AngelFlag.transform.position.y > 0)
                 {
                     respawnRandomizer = Random.Range(0, 2);
                     if (this.gameObject.name == "Urial")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation2;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation4;
                         }
                     }
                     else if (this.gameObject.name == "Barachial")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation1;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation3;
                         }
                     }
                 }
                 else if (AngelFlag.transform.position.y <= 0)
                 {
                     respawnRandomizer = Random.Range(0, 2);
                     if (this.gameObject.name == "Urial")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation1;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation3;
                         }
                     }
                     else if (this.gameObject.name == "Barachial")
                     {
                         if (respawnRandomizer == 0)
                         {
                             transform.position = SpawnLocation2;
                         }
                         else if (respawnRandomizer == 1)
                         {
                             transform.position = SpawnLocation4;
                         }
                     }
                 }
             }
             else if (AngelFlag.GetComponent <FlagScript>().inBase)
             {
                 respawnRandomizer = Random.Range(0, 4);
                 if (respawnRandomizer == 0)
                 {
                     transform.position = SpawnLocation1;
                 }
                 else if (respawnRandomizer == 1)
                 {
                     transform.position = SpawnLocation2;
                 }
                 else if (respawnRandomizer == 2)
                 {
                     transform.position = SpawnLocation3;
                 }
                 else if (respawnRandomizer == 3)
                 {
                     transform.position = SpawnLocation4;
                 }
             }
             if (this.gameObject.name == "Urial")
             {
                 Instantiate(urialRespawnIndicator, this.gameObject.transform.position, Quaternion.identity);
             }
             else if (this.gameObject.name == "Barachial")
             {
                 Instantiate(barachialRespawnIndicator, this.gameObject.transform.position, Quaternion.identity);
             }
         }
         shield.GetComponent <ShieldScript>().shieldLife = 3;
         Invoke("Respawn", respawnTimer);
         GameObject.Find("Main Camera").GetComponent <CameraScript>().shakeDuration = .2f;
         Invoke("StopShake", .2f);
         #endregion
     }
 }
Esempio n. 6
0
 void OnTriggerEnter2D(Collider2D other)
 {
     // How you interact with flags will differ depending on your player type.
     if (this.gameObject.CompareTag("Angel"))
     {
         // if an angel hits a demon flag, pick it up if its not being thrown, you're not meleeing, and its not being returned
         if (other.gameObject.CompareTag("Demon Flag"))
         {
             if (!other.gameObject.GetComponent <FlagScript>().beingThrown&& !meleeing && !other.gameObject.GetComponent <FlagScript>().beingReturned)
             {
                 if (this.gameObject.name == "Urial" && GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().barachialAlive)
                 {
                     if (GameObject.Find("Barachial").GetComponent <PlayerScript>().hasFlag == false)
                     {
                         DemonFlag.GetComponent <FlagScript>().FlagRunesOff();
                         hasFlag = true;
                         CancelInvoke("EndFlagThrow");
                     }
                 }
                 else if (this.gameObject.name == "Urial" && !GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().barachialAlive)
                 {
                     DemonFlag.GetComponent <FlagScript>().FlagRunesOff();
                     hasFlag = true;
                     CancelInvoke("EndFlagThrow");
                 }
                 else if (this.gameObject.name == "Barachial" && GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().urialAlive)
                 {
                     if (GameObject.Find("Urial").GetComponent <PlayerScript>().hasFlag == false)
                     {
                         DemonFlag.GetComponent <FlagScript>().FlagRunesOff();
                         hasFlag = true;
                         CancelInvoke("EndFlagThrow");
                     }
                 }
                 else if (this.gameObject.name == "Barachial" && !GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().urialAlive)
                 {
                     DemonFlag.GetComponent <FlagScript>().FlagRunesOff();
                     hasFlag = true;
                     CancelInvoke("EndFlagThrow");
                 }
             }
         }
     }
     else if (this.gameObject.CompareTag("Demon"))
     {
         //else if youre a demon and hit the angel flag while its not moving, youre not meleeing, and its not being returned
         if (other.gameObject.CompareTag("Angel Flag"))
         {
             if (!other.gameObject.GetComponent <FlagScript>().beingThrown&& !meleeing && !other.gameObject.GetComponent <FlagScript>().beingReturned)
             {
                 if (this.gameObject.name == "Azazel" && GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().lilithAlive)
                 {
                     if (!GameObject.Find("Lilith").GetComponent <PlayerScript>().hasFlag)
                     {
                         AngelFlag.GetComponent <FlagScript>().FlagRunesOff();
                         hasFlag = true;
                         CancelInvoke("EndFlagThrow");
                     }
                 }
                 else if (this.gameObject.name == "Azazel" && !GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().lilithAlive)
                 {
                     AngelFlag.GetComponent <FlagScript>().FlagRunesOff();
                     hasFlag = true;
                     CancelInvoke("EndFlagThrow");
                 }
                 else if (this.gameObject.name == "Lilith" && GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().azazelAlive)
                 {
                     if (!GameObject.Find("Azazel").GetComponent <PlayerScript>().hasFlag)
                     {
                         AngelFlag.GetComponent <FlagScript>().FlagRunesOff();
                         hasFlag = true;
                         CancelInvoke("EndFlagThrow");
                     }
                 }
                 else if (this.gameObject.name == "Lilith" && !GameObject.Find("DeathTracker").GetComponent <DeathTrackerScript>().azazelAlive)
                 {
                     AngelFlag.GetComponent <FlagScript>().FlagRunesOff();
                     hasFlag = true;
                     CancelInvoke("EndFlagThrow");
                 }
             }
         }
     }
 }
Esempio n. 7
0
    private void ProcessInput()
    {
        // Process movement
        // If you don't have a flag and aren't shielding, move at normal speed
        if (!blocking && !hasFlag)
        {
            GetComponent <Rigidbody2D>().velocity = new Vector2(moveVector.x, moveVector.y) * moveSpeed;
        }
        // If you are blocking or have the flag, move at slow speed
        else if (blocking || hasFlag)
        {
            GetComponent <Rigidbody2D>().velocity = new Vector2(moveVector.x, moveVector.y) * slowMoveSpeed;
        }
        // If you are meleeing, move at melee speed and turn on the shield's ability to kill things.

        // Process rotation
        if ((xSpeed != 0 || ySpeed != 0) && !meleeing)
        {
            gameObject.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, (Mathf.Atan2(xSpeed, ySpeed) * Mathf.Rad2Deg));
        }
        // Process fire
        if (firing && canFire && !blocking && !hasFlag)
        {
            canFire = false;
            GameObject bullet = (Instantiate(bulletPrefab, new Vector3(bulletSpawner.transform.position.x, bulletSpawner.transform.position.y, -1.5f), bulletSpawner.transform.rotation)) as GameObject;
            if (this.gameObject.CompareTag("Angel"))
            {
                if ((GameObject.FindGameObjectWithTag("ShotPowerUp") != null && GameObject.FindGameObjectWithTag("ShotPowerUp").GetComponent <shotsPowerUp>().angelShotPowerUp) || PlayerPrefs.GetInt("shotSpeedModifier") == 1)
                {
                    Invoke("CanShootAgain", 0.5f);
                }
                else
                {
                    Invoke("CanShootAgain", reloadSpeed);
                }
            }
            if (this.gameObject.CompareTag("Demon"))
            {
                if ((GameObject.FindGameObjectWithTag("ShotPowerUp") != null && GameObject.FindGameObjectWithTag("ShotPowerUp").GetComponent <shotsPowerUp>().demonShotPowerUp) || PlayerPrefs.GetInt("shotSpeedModifier") == 1)
                {
                    Invoke("CanShootAgain", 0.5f);
                }
                else
                {
                    Invoke("CanShootAgain", reloadSpeed);
                }
            }
            //shot indicator cooldown for all characters
            if (this.gameObject.name == "Urial")
            {
                GameObject.Find("Urial Shot Indicator").GetComponent <ShotCooldownIndicator>().UrialShotCooldown();
            }
            else if (this.gameObject.name == "Barachial")
            {
                GameObject.Find("Barachial Shot Indicator").GetComponent <ShotCooldownIndicator>().BarachialShotCooldown();
            }
            else if (this.gameObject.name == "Lilith")
            {
                GameObject.Find("Lilith Shot Indicator").GetComponent <ShotCooldownIndicator>().LilithShotCooldown();
            }
            else if (this.gameObject.name == "Azazel")
            {
                GameObject.Find("Azazel Shot Indicator").GetComponent <ShotCooldownIndicator>().AzazelShotCooldown();
            }
        }
        // Process flag throw
        if (firing && hasFlag && canThrowFlag)
        {
            //if this object is an Angel
            if (this.gameObject.CompareTag("Angel"))
            {
                canThrowFlag = false;
                GetComponent <AudioSource>().PlayOneShot(Toss);
                //remove the flag from it
                hasFlag = false;
                Debug.Log(this.gameObject.name + "has thrown the demon flag!");
                //let the demonflag know that it is now being thrown and is no longer on the player
                DemonFlag.GetComponent <FlagScript>().beingThrown = true;
                //after a one second delay, call a function that tells the demon flag to stop moving
                Invoke("EndFlagThrow", DemonFlag.GetComponent <FlagScript>().throwSpeed);
                //re allow the player to fire regular projectiles
                Invoke("CanShootAgain", 0.5f);
                Invoke("CanThrowAgain", 0.5f);
                //re allow the player to shield
                canShield = true;
                Invoke("CanMeleeDelay", 0.5f);
            }

            //same as above but for the demon
            if (this.gameObject.CompareTag("Demon"))
            {
                canThrowFlag = false;
                GetComponent <AudioSource>().PlayOneShot(Toss);
                //
                hasFlag = false;
                Debug.Log(this.gameObject.name + "has thrown the angel flag!");
                //
                AngelFlag.GetComponent <FlagScript>().beingThrown = true;
                //
                Invoke("EndFlagThrow", AngelFlag.GetComponent <FlagScript>().throwSpeed);
                //
                Invoke("CanShootAgain", 0.5f);
                Invoke("CanThrowAgain", 0.5f);
                //
                canShield = true;
                Invoke("CanMeleeDelay", 0.5f);
            }
        }

        // Process melee
        if (blocking && canMelee && !hasFlag)
        {
            if (firing)
            {
                GetComponent <AudioSource>().PlayOneShot(Dash);
                canMelee = false;
                meleeing = true;
                if (this.gameObject.name == "Urial")
                {
                    GameObject.Find("Urial Melee Indicator").GetComponent <MeleeCooldownIndicator>().UrialMeleeCooldown();
                }
                else if (this.gameObject.name == "Barachial")
                {
                    GameObject.Find("Barachial Melee Indicator").GetComponent <MeleeCooldownIndicator>().BarachialMeleeCooldown();
                }
                else if (this.gameObject.name == "Lilith")
                {
                    GameObject.Find("Lilith Melee Indicator").GetComponent <MeleeCooldownIndicator>().LilithMeleeCooldown();
                }
                else if (this.gameObject.name == "Azazel")
                {
                    GameObject.Find("Azazel Melee Indicator").GetComponent <MeleeCooldownIndicator>().AzazelMeleeCooldown();
                }
                StartCoroutine(StopMelee());
            }
        }

        // Process shield
        if (blocking && canShield && !hasFlag)
        {
            shield.gameObject.GetComponent <PolygonCollider2D>().enabled = true;
            shield.gameObject.GetComponent <SpriteRenderer>().enabled    = true;
        }
        else if (!blocking || !canShield || hasFlag)
        {
            shield.gameObject.GetComponent <PolygonCollider2D>().enabled = false;
            shield.gameObject.GetComponent <SpriteRenderer>().enabled    = false;
        }
    }