Пример #1
0
 // Use this for initialization
 void Start()
 {
     rectTransform       = gameObject.GetComponent <RectTransform>();
     thisHealthandDamage = gameObject.GetComponentInParent <HealthAndDamage>();
     newscale            = thisHealthandDamage.newscale;
     player = GameObject.FindGameObjectWithTag("Player");
 }
Пример #2
0
    void Instantiate_Spell1(Vector3 center, float radius)
    {
        source.PlayOneShot(spell1Ac);
        playSpellAnimation();

        // Store all colliders that overlapSphere hits and apply damage to enemmies
        Collider[] hitColliders = Physics.OverlapSphere(center, radius);
        int        i            = 0;

        while (i < hitColliders.Length)
        {
            if (iAmOnTheRedTeam && hitColliders[i].transform.tag == "BlueTeamTrigger")
            {
                PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                HealthAndDamage HDScript = hitColliders[i].transform.GetComponent <HealthAndDamage>();

                HDScript.spellDamage      = plstats.spellStat;
                HDScript.iWasJustAttacked = true;
                HDScript.hitBySpell1      = true;
            }
            if (iAmOnTheBlueTeam && hitColliders[i].transform.tag == "RedTeamTrigger")
            {
                PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                HealthAndDamage HDScript = hitColliders[i].transform.GetComponent <HealthAndDamage>();

                HDScript.spellDamage      = plstats.spellStat;
                HDScript.iWasJustAttacked = true;
                HDScript.hitBySpell1      = true;
            }
            i++;
        }
    }
Пример #3
0
    IEnumerator AssignHealthOnJoiningGame()
    {
        // Do not execute the code until the wait time has elapsed
        yield return(new WaitForSeconds(waitTime));

        // Find the Trigger Game Objects of all players in both teams
        // and place a reference to these in the two arrays
        redTeamPlayers  = GameObject.FindGameObjectsWithTag("RedTeamTrigger");
        blueTeamPlayers = GameObject.FindGameObjectsWithTag("BlueTeamTrigger");

        // Assign the buffered previousHealth value to the player's current health
        // If we did not do this then a new player joining the game, would have an
        // incorrect value of everyones health, as they would all appear to have
        // full health, even though they do not
        foreach (GameObject red in redTeamPlayers)
        {
            HealthAndDamage HDScript = red.GetComponent <HealthAndDamage>();
            HDScript.myHealth = HDScript.previousHealth;
        }

        foreach (GameObject blue in blueTeamPlayers)
        {
            HealthAndDamage HDScript = blue.GetComponent <HealthAndDamage>();
            HDScript.myHealth = HDScript.previousHealth;
        }

        // Disable this script as we only needed it once
        enabled = false;
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        // This script will run for all players.
        if (networkView.isMine == true || networkView.isMine == false)
        {
            myTransform = transform;
            myCamera    = Camera.main;

            Transform triggerTransform = transform.FindChild("Trigger");
            HDScript = triggerTransform.GetComponent <HealthAndDamage>();

            // The font color of the GUIStyle depends on which team the player is on
            if (myTransform.tag == "Blue Team")
            {
                myStyle.normal.textColor = Color.cyan;
            }
            if (myTransform.tag == "Red Team")
            {
                myStyle.normal.textColor = Color.red;
            }

            myStyle.fontSize  = 12;
            myStyle.fontStyle = FontStyle.Bold;
            myStyle.clipping  = TextClipping.Overflow;            // Allow the text to extend beyond the width of the label
        }
        else
        {
            enabled = false;
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        // Translate the projectile in the up direction (the pointed end of the projectile).
        myTransform.Translate(Vector3.up * projectileSpeed * Time.deltaTime);

        //If the ray hits something then execute this code.
        if (Physics.Raycast(myTransform.position, myTransform.up, out hit, range) && expended == false)
        {
            //If the collider has the tag of map then..
            if (hit.transform.tag == "map")
            {
                expended = true;

                //Instantiate an explosion effect.
                Instantiate(projectileExplosion, hit.point, Quaternion.identity);

                //Destroy the projectile from the scene.
                Destroy(myTransform.gameObject);
            }

            if (hit.transform.tag == "RedTeamTrigger" || hit.transform.tag == "BlueTeamTrigger")
            {
                expended = true;

                //Instantiate an explosion effect.
                Instantiate(projectileExplosion, hit.point, Quaternion.identity);

                //Destroy the projectile from the scene.
                Destroy(myTransform.gameObject);

                // Access the HealthAndDamage Script of the enemy player and inform them that they have been attacked.
                // Also set the projectile damage equal to the attackStat of the player
                if (hit.transform.tag == "BlueTeamTrigger" && team == "red")
                {
                    PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();

                    HDScript.attackDamage     = plstats.attackStat;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitByProjectile  = true;
                }

                // Access the HealthAndDamage Script of the enemy player and inform them that they have been attacked.
                // Also set the projectile damage equal to the attackStat of the player
                if (hit.transform.tag == "RedTeamTrigger" && team == "blue")
                {
                    PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();

                    HDScript.attackDamage     = plstats.attackStat;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitByProjectile  = true;
                }
            }
        }
    }
Пример #6
0
    void applyDamageBleed(Collider[] colliderList, int counter, PlayerStats playerStats, float bleedDuration)
    {
        HealthAndDamage HDScript = colliderList[counter].transform.GetComponent <HealthAndDamage>();

        HDScript.spellDamage      = playerStats.spellStat * 2;
        HDScript.iWasJustAttacked = true;
        HDScript.bleed            = true;
        HDScript.bleedInstantiate = true;
        HDScript.bleedTime        = bleedDuration;
    }
Пример #7
0
    void Instantiate_Spell1(Vector3 center, float radius)
    {
        source.PlayOneShot(spell1Ac);
        playSpellAnimation(healDamageAnimation);

        //	Collect all colliders that collide within the sphere of spell 1
        Collider[] hitColliders = Physics.OverlapSphere(center, radius);
        int        i            = 0;

        while (i < hitColliders.Length)
        {
            //	Determines which are oponents and applies damage to them
            if (iAmOnTheRedTeam && hitColliders[i].transform.tag == "BlueTeamTrigger")
            {
                PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                HealthAndDamage HDScript = hitColliders[i].transform.GetComponent <HealthAndDamage>();

                HDScript.spellDamage      = plstats.spellStat;
                HDScript.iWasJustAttacked = true;
                HDScript.hitBySpell1      = true;
            }
            if (iAmOnTheBlueTeam && hitColliders[i].transform.tag == "RedTeamTrigger")
            {
                PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                HealthAndDamage HDScript = hitColliders[i].transform.GetComponent <HealthAndDamage>();

                HDScript.spellDamage      = plstats.spellStat;
                HDScript.iWasJustAttacked = true;
                HDScript.hitBySpell1      = true;
            }


            //	Determines which are allies and applies healing to them
            if (iAmOnTheRedTeam && hitColliders[i].transform.tag == "RedTeamTrigger")
            {
                PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                HealthAndDamage HDScript = hitColliders[i].transform.GetComponent <HealthAndDamage>();

                HDScript.healingValue = plstats.spellStat;
                HDScript.applyHeal    = true;
            }

            if (iAmOnTheBlueTeam && hitColliders[i].transform.tag == "BlueTeamTrigger")
            {
                PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                HealthAndDamage HDScript = hitColliders[i].transform.GetComponent <HealthAndDamage>();

                HDScript.healingValue = plstats.spellStat;
                HDScript.applyHeal    = true;
            }
            i++;
        }
    }
Пример #8
0
    void HealSelf(Vector3 position, Quaternion rotation)
    {
        source.PlayOneShot(spell1Ac);

        GameObject healParticle = (GameObject)Instantiate(spell1Effect, position, rotation);

        healParticle.gameObject.transform.parent = this.gameObject.transform;

        PlayerStats     plStats  = gameObject.GetComponent <PlayerStats>();
        HealthAndDamage HDScript = gameObject.GetComponentInChildren <HealthAndDamage>();

        HDScript.healingValue = plStats.spellStat;
        HDScript.applyHeal    = true;
    }
Пример #9
0
    //Variables End_____________________________________


    void Awake()
    {
        //This script will only run for the other player characters.
        //We don't need a health bar being drawn above our own player in
        //our game.

        if (networkView.isMine == false)
        {
            myTransform = transform;

            myCamera = Camera.main;


            //Access the HealthAndDamage script.

            Transform triggerTransform = transform.FindChild("Trigger");

            HDScript = triggerTransform.GetComponent <HealthAndDamage>();


            //The font colour of the GUIStyle depends on which team the
            //player is on.

            if (myTransform.tag == "BlueTeam")
            {
                myStyle.normal.textColor = Color.blue;
            }

            if (myTransform.tag == "RedTeam")
            {
                myStyle.normal.textColor = Color.red;
            }
            myStyle.fontSize  = 12;
            myStyle.fontStyle = FontStyle.Bold;
            //Allow the text to extend beyond the width of the label.
            myStyle.clipping = TextClipping.Overflow;

            blackBorder.normal.textColor = Color.black;
            blackBorder.fontSize         = 12;
            blackBorder.fontStyle        = FontStyle.Bold;
            blackBorder.clipping         = TextClipping.Overflow;
        }

        else
        {
            enabled = false;
        }
    }
Пример #10
0
        private void OnTriggerEnter(Collider other)
        {
            Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);
            foreach (Collider collider in colliders)
            {
                HealthAndDamage healthAndDamage = collider.GetComponent <HealthAndDamage>();
                if (healthAndDamage != null)
                {
                    healthAndDamage.ReduceHealth(damageAmountSetter.damageAmount);
                }
            }

            CameraShaker.Instance.ShakeOnce(3, 3, 2, 0.3f);
            Instantiate(explosionEffect, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
Пример #11
0
    void Update()
    {
        myTransform.Translate(Vector3.up * projectileSpeed * Time.deltaTime);

        if (Physics.Raycast(myTransform.position, myTransform.up, out hit, range) &&
            expended == false)
        {
            if (hit.transform.tag == "Map" || hit.transform.tag == "Floor")
            {
                expended = true;

                Instantiate(rocketExplosion, hit.point, Quaternion.identity);

                myTransform.renderer.enabled = false;
                myTransform.light.enabled    = false;
            }

            if (hit.transform.tag == "BlueTeamTrigger" || hit.transform.tag == "RedTeamTrigger")
            {
                expended = true;

                Instantiate(rocketExplosion, hit.point, Quaternion.identity);

                myTransform.renderer.enabled = false;
                myTransform.light.enabled    = false;


                //Access the HealthAndDamage script of the enemy player
                //and inform them that they have been attacked and by who.
                if (hit.transform.tag == "BlueTeamTrigger" && team == "red")
                {
                    HealthAndDamage HDscript = hit.transform.GetComponent <HealthAndDamage>();
                    HDscript.iWasJustAttacked = true;
                    HDscript.myAttacker       = myOriginator;
                    HDscript.hitByRocket      = true;
                }

                if (hit.transform.tag == "RedTeamTrigger" && team == "blue")
                {
                    HealthAndDamage HDscript = hit.transform.GetComponent <HealthAndDamage>();
                    HDscript.iWasJustAttacked = true;
                    HDscript.myAttacker       = myOriginator;
                    HDscript.hitByRocket      = true;
                }
            }
        }
    }
Пример #12
0
    // Variables end______________________
    // Use this for initialization
    void Start()
    {
        if(networkView.isMine == true)
        {
            // Access the HealthAndDamage script
            Transform triggerTransform = transform.FindChild("Trigger");
            HDScript = triggerTransform.GetComponent<HealthAndDamage>();

            // Set the GUI style
            healthStyle.normal.textColor = Color.green;
            healthStyle.fontStyle = FontStyle.Bold;
        }
        else
        {
            enabled = false;
        }
    }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     if (networkView.isMine)
     {
         shop = gameObject.GetComponent <ShopKeeper>();
         inv  = gameObject.GetComponent <InventoryGrid>();
         Transform triggerTransform = transform.FindChild("Trigger");
         HDScript    = triggerTransform.GetComponent <HealthAndDamage>();
         manaScript  = gameObject.GetComponent <Mana>();
         playerStats = gameObject.GetComponent <PlayerStats>();
         move        = gameObject.GetComponent <PointAndClickMovement>();
     }
     else
     {
         enabled = false;
     }
 }
    //Variables End_____________________________________
    void Awake()
    {
        //This script will only run for the other player characters.
        //We don't need a health bar being drawn above our own player in
        //our game.

        if(networkView.isMine == false)
        {
            myTransform = transform;

            myCamera = Camera.main;

            //Access the HealthAndDamage script.

            Transform triggerTransform = transform.FindChild("Trigger");

            HDScript = triggerTransform.GetComponent<HealthAndDamage>();

            //The font colour of the GUIStyle depends on which team the
            //player is on.

            if(myTransform.tag == "BlueTeam")
            {
                myStyle.normal.textColor = Color.blue;
            }

            if(myTransform.tag == "RedTeam")
            {
                myStyle.normal.textColor = Color.red;
            }
            myStyle.fontSize = 12;
            myStyle.fontStyle = FontStyle.Bold;
            //Allow the text to extend beyond the width of the label.
            myStyle.clipping = TextClipping.Overflow;

            blackBorder.normal.textColor = Color.black;
            blackBorder.fontSize = 12;
            blackBorder.fontStyle = FontStyle.Bold;
            blackBorder.clipping = TextClipping.Overflow;
        }

        else
        {
            enabled = false;
        }
    }
Пример #15
0
    // Variables end______________________


    // Use this for initialization
    void Start()
    {
        if (networkView.isMine == true)
        {
            // Access the HealthAndDamage script
            Transform triggerTransform = transform.FindChild("Trigger");
            HDScript = triggerTransform.GetComponent <HealthAndDamage>();

            // Set the GUI style
            healthStyle.normal.textColor = Color.green;
            healthStyle.fontStyle        = FontStyle.Bold;
        }
        else
        {
            enabled = false;
        }
    }
Пример #16
0
    void MeleeAttack(Vector3 center, float radius, string originatorName, float attackSpeed)
    {
        source.PlayOneShot(meleeAc);

        animation[attackAnim.name].layer    = 1;
        animation[attackAnim.name].speed    = 2 * (1 / attackSpeed);
        animation[attackAnim.name].wrapMode = WrapMode.Once;
        animation.CrossFade(attackAnim.name);

        Collider[] collider = Physics.OverlapSphere(center, radius);
        int        i        = 0;

        while (i < collider.Length)
        {
            if (iAmOnTheRedTeam && collider[i].transform.tag == "BlueTeamTrigger")
            {
                //Check if enemy is in an angle in front of attacker and then apply the damage and the rest
                if (Vector3.Angle(transform.forward, collider[i].transform.position - transform.position) < 60)
                {
                    PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = collider[i].transform.GetComponent <HealthAndDamage>();

                    HDScript.attackDamage     = plstats.attackStat;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitByMelee       = true;
                }
            }
            if (iAmOnTheBlueTeam && collider[i].transform.tag == "RedTeamTrigger")
            {
                //Check if enemy is in an angle in front of attacker and then apply the damage and the rest
                if (Vector3.Angle(transform.forward, collider[i].transform.position - transform.position) < 60)
                {
                    PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = collider[i].transform.GetComponent <HealthAndDamage>();

                    HDScript.attackDamage     = plstats.attackStat;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitByMelee       = true;
                }
            }
            i++;
        }
    }
Пример #17
0
    void jumpAttack(Vector3 center, float radius)
    {
        source.PlayOneShot(spell2Ac);
        playSpellAnimation(jumpAttackAnimation);
        rotatePlayerOnAttack();

        Collider[] collider = Physics.OverlapSphere(center, radius);
        int        i        = 0;

        while (i < collider.Length)
        {
            if (iAmOnTheRedTeam && collider[i].transform.tag == "BlueTeamTrigger")
            {
                //Check if enemy is in a 60 degrees angle in front of attacker and then apply the damage and the rest
                if (Vector3.Angle(transform.forward, collider[i].transform.position - transform.position) < 60)
                {
                    PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = collider[i].transform.GetComponent <HealthAndDamage>();

                    HDScript.spellDamage      = plstats.spellStat;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitBySpell1      = true;
                }
            }

            if (iAmOnTheBlueTeam && collider[i].transform.tag == "RedTeamTrigger")
            {
                //Check if enemy is in a 60 degrees angle in front of attacker and then apply the damage and the rest
                if (Vector3.Angle(transform.forward, collider[i].transform.position - transform.position) < 60)
                {
                    PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = collider[i].transform.GetComponent <HealthAndDamage>();

                    HDScript.spellDamage      = plstats.spellStat;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitBySpell1      = true;
                }
            }
            i++;
        }
    }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        // Define the player's statistics window.
        statWindow = new Rect(nativeWidth - (nativeWidth - 1150), nativeHeight - 200, 200, 230);

        if (networkView.isMine)
        {
            teamSelectionScript = GameObject.Find("SpawnManager").GetComponent <CharacterSelection>();
            Transform triggerTransform = transform.FindChild("Trigger");
            HDScript   = triggerTransform.GetComponent <HealthAndDamage>();
            moveScript = transform.GetComponent <PointAndClickMovement>();
            spawn      = GameObject.Find("SpawnManager").GetComponent <SpawnScript>();

            // Assign the player's stats when a character is selected.
            AssignPlayerStats();
        }
        else
        {
            enabled = false;
        }
    }
Пример #19
0
    // Use this for initialization
    void Start()
    {
        if (networkView.isMine == true)
        {
            // Access HealthAndDamage script and the Mana script

            Transform triggerTransform = transform.FindChild("Trigger");

            HDScript   = triggerTransform.GetComponent <HealthAndDamage>();
            manaScript = gameObject.GetComponent <Mana>();

            // Set the GuiStyle

            //healthStyle.normal.textColor = Color.black;
            //healthStyle.fontStyle = FontStyle.Bold;
        }
        else
        {
            enabled = false;
        }
    }
Пример #20
0
    IEnumerator AssignHealthOnJoiningGame()
    {
        //Don't execute the code till the wait time has
        //elapsed.

        yield return(new WaitForSeconds(waitTime));


        //Find the Trigger GameObjects of all players in both teams and
        //place a reference to them in the two arrays.

        redTeamPlayers = GameObject.FindGameObjectsWithTag("RedTeamTrigger");

        blueTeamPlayers = GameObject.FindGameObjectsWithTag("BlueTeamTrigger");


        //Assign the buffered previous health value to the player's current health.
        //If we didn't do this then a newcomer to the game would have an incorrect
        //picture of everyone's health as everyone would appear to have health.

        foreach (GameObject red in redTeamPlayers)
        {
            HealthAndDamage HDScript = red.GetComponent <HealthAndDamage>();

            HDScript.myHealth = HDScript.previousHealth;
        }

        foreach (GameObject blue in blueTeamPlayers)
        {
            HealthAndDamage HDScript = blue.GetComponent <HealthAndDamage>();

            HDScript.myHealth = HDScript.previousHealth;
        }


        //Disable this script as we only needed it once.

        enabled = false;
    }
Пример #21
0
    //Variables End___________________________________________________________
    // Use this for initialization
    void Start()
    {
        if(networkView.isMine == true)
        {
            myTransform = transform;

            Transform trig = myTransform.FindChild("Trigger");

            HDScript = trig.GetComponent<HealthAndDamage>();

            GameObject gameManager = GameObject.Find("GameManager");

            PlayerStats script = gameManager.GetComponent<PlayerStats>();

            previousHealth = script.maxHealth;
        }

        else
        {
            enabled = false;
        }
    }
Пример #22
0
    // Use this for initialization
    void Start()
    {
        if(networkView.isMine == true)
        {
            Transform triggerTransform = transform.FindChild("Trigger");
            HDScript = triggerTransform.GetComponent<HealthAndDamage>();

            energyScript = gameObject.GetComponent<PlayerEnergy>();
            rescourceScript = gameObject.GetComponent<PlayerResource>();

            healthStyle.normal.textColor = Color.red;
            healthStyle.fontStyle = FontStyle.Bold;
            energyStyle.normal.textColor = Color.cyan;
            energyStyle.fontStyle = FontStyle.Bold;
            rescourcesStyle.normal.textColor = Color.green;
            rescourcesStyle.fontStyle = FontStyle.Bold;

        }
        else
        {
            enabled = false;
        }
    }
Пример #23
0
    // Update is called once per frame
    void Update()
    {
        // Translate the projectile in the up direction (the pointed end of the projectile).
        myTransform.Translate(Vector3.up * projectileSpeed * Time.deltaTime);

        //If the ray hits something then execute this code.
        if (Physics.Raycast(myTransform.position, myTransform.up, out hit, range) &&
            expended == false)
        {
            //If the collider has the tag of Floor then..
            if (hit.transform.tag == "map")
            {
                expended = true;

                //Instantiate an explosion effect.
                Instantiate(projectileExplosion, hit.point, Quaternion.identity);

                //Destroy the projectile from the scene.
                Destroy(myTransform.gameObject);
            }

            if (hit.transform.tag == "RedTeamTrigger" || hit.transform.tag == "BlueTeamTrigger")
            {
                expended = true;

                //Instantiate an explosion effect.
                Instantiate(projectileExplosion, hit.point, Quaternion.identity);

                //Destroy the projectile from the scene.
                Destroy(myTransform.gameObject);

                // Access the HealthAndDamage Script of the enemy player and inform them that they have been attacked.
                // Also set the projectile damage equal to the spellStat of the player or apply slow according wich spell has been cast
                if (hit.transform.tag == "BlueTeamTrigger" && team == "red")
                {
                    if (arrowsSlow)
                    {
                        PointAndClickMovement move = hit.transform.parent.gameObject.GetComponent <PointAndClickMovement>();
                        float slowRate             = 2f;
                        int   slowDuration         = 5;
                        move.Slow(slowRate, slowDuration);
                        arrowsSlow = false;
                    }

                    if (bigArrow)
                    {
                        PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                        HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();

                        HDScript.spellDamage      = plstats.spellStat * 2;
                        HDScript.iWasJustAttacked = true;
                        HDScript.hitBySpell1      = true;
                        bigArrow = false;
                    }
                }

                // Access the HealthAndDamage Script of the enemy player and inform them that they have been attacked.
                // Also set the projectile damage equal to the spellStat of the player or apply slow according wich spell has been cast
                if (hit.transform.tag == "RedTeamTrigger" && team == "blue")
                {
                    if (arrowsSlow)
                    {
                        PointAndClickMovement move = hit.transform.parent.gameObject.GetComponent <PointAndClickMovement>();
                        float slowRate             = 2f;
                        int   slowDuration         = 5;
                        move.Slow(slowRate, slowDuration);
                        arrowsSlow = false;
                    }

                    if (bigArrow)
                    {
                        PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                        HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();

                        HDScript.spellDamage      = plstats.spellStat * 2;
                        HDScript.iWasJustAttacked = true;
                        HDScript.hitBySpell1      = true;
                        bigArrow = false;
                    }
                }
            }
        }
    }
Пример #24
0
    // Update is called once per frame
    void Update()
    {
        // Translate the projectile in the UP direction (the pointed
        // end of the projectile).
        // v = d/t; new_d = v * time
        myTransform.Translate(Vector3.up * projectileSpeed * Time.deltaTime);

        // If the ray hits something then execute this code
        if (Physics.Raycast(myTransform.position, myTransform.up, out hit, range) &&
            expended == false)
        {
            // If the collider has the tag of Floor then..
            if (hit.transform.tag == "Floor")
            {
                // Instantiate an explosion effect
                Instantiate(BlasterExplosion, hit.point, Quaternion.identity);

                expended = true;

                // Make the projectile become invisible
                myTransform.renderer.enabled = false;

                // Turn off its light so that the halo also dissapears
                myTransform.light.enabled = false;
            }

            if (hit.transform.tag == "BlueTeamTrigger" ||
                hit.transform.tag == "RedTeamTrigger")
            {
                expended = true;

                // Instantiate an explosion effect
                Instantiate(BlasterExplosion, hit.point, Quaternion.identity);

                // Make the projectile become invisible
                myTransform.renderer.enabled = false;

                // Turn off its light so that the halo also dissapears
                myTransform.light.enabled = false;

                // Access the HealthAndDamage script of the enemy player
                // and inform them that they have been attacked and by
                // whom
                if (hit.transform.tag == "BlueTeamTrigger" && team == "red")
                {
                    HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();
                    HDScript.iWasJustAttacked = true;
                    HDScript.myAttacker       = myOriginator;
                    HDScript.hitByBlaster     = true;
                }

                if (hit.transform.tag == "RedTeamTrigger" && team == "blue")
                {
                    HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();
                    HDScript.iWasJustAttacked = true;
                    HDScript.myAttacker       = myOriginator;
                    HDScript.hitByBlaster     = true;
                }
            }
        }
    }
Пример #25
0
    //varibles end --------------------------------------------------
    // Use this for initialization
    void Start()
    {
        //This only runs for other player charicters
        if(networkView.isMine == true)
        {
            enabled = false;
        }

        myTransform = transform;

        myCamera = Camera.main;

        //the font color of the GUIstyle depends on which theam the player is on
        if(myTransform.tag == "BlueTeam")
        {
            myStyle.normal.textColor = Color.blue;
        }
        if(myTransform.tag == "RedTeam")
        {
            myStyle.normal.textColor = Color.red;
        }

        myStyle.fontSize = 12;

        myStyle.fontStyle = FontStyle.Bold;

        //allow the text to extend beyond
        myStyle.clipping = TextClipping.Overflow;

        Transform triggerTransform = transform.FindChild("Trigger");

        HDScript = triggerTransform.GetComponent<HealthAndDamage>();
    }