Example #1
0
 /// <summary>
 /// Start this instance.
 /// </summary>
 void Start()
 {
     desiredPlayer      = GameObject.FindGameObjectsWithTag("Player2");
     battle             = desiredPlayer[0].GetComponent <BattleTimeScript>();
     constVar           = GameObject.FindGameObjectWithTag("Constant");
     stored             = constVar.GetComponent <StoredInformation>();
     attacking          = new PlayerAttack();
     attackingWithMagic = new MagicAttack();
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2");

        if (enemyObjects.Length != 0)
        {
            GameObject        constVar = GameObject.FindGameObjectWithTag("Constant");
            StoredInformation stored   = constVar.GetComponent <StoredInformation>();
            int counter = stored.BattlePosition;

            PlayerAttack playerAttack;
            GameObject[] obj = GameObject.FindGameObjectsWithTag("Player2");
            playerAttack = obj[counter].GetComponent <PlayerAttack>();

            enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2");

            BattleAttackDisplay bat = obj[counter].GetComponent <BattleAttackDisplay>();
            fighterNumber = bat.EnemyNumber;
            EnemyTarget   = enemyObjects[fighterNumber];

            if (EnemyTarget == null)
            {
                EnemyTarget = enemyObjects[fighterNumber + 1];
            }

            if (characterTransform == null)
            {
                characterTransform = transform;
            }

            if (attemptAttack)
            {
                Quaternion rot;

                Vector3 lookRotate = EnemyTarget.transform.position - characterTransform.position;
                rot = Quaternion.Slerp(characterTransform.rotation, Quaternion.LookRotation(lookRotate), 3 * Time.deltaTime);
                characterTransform.rotation = rot;
                characterTransform          = GameObject.FindGameObjectWithTag("Player2").transform;
                Vector3 charPosition = new Vector3(characterTransform.forward.x * 8 * Time.deltaTime,
                                                   0,
                                                   characterTransform.forward.z * 8 * Time.deltaTime);
                characterTransform.position += charPosition;
                animation.Play("Run");
            }
            if (Vector3.Distance(characterTransform.position, EnemyTarget.transform.position) <= 1)
            {
                EnemyTarget = enemyObjects[fighterNumber];

                EnemyHealth attackEnemy = EnemyTarget.GetComponent <EnemyHealth>();
                attackType = bat.attackType;
                if (attackType == "Attack")
                {
                    attackEnemy.AddjustCurrentHealth(stored._attackValue[0], "minus");
                }
                if (attackType == "FireAttack")
                {
                    initialiseParticles      = Instantiate(particles[0], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Fire";

                    attackEnemy.AddjustCurrentHealth(stored._attackValue[1], "minus");
                }
                if (attackType == "IceAttack")
                {
                    attackEnemy.AddjustCurrentHealth(stored._attackValue[2], "minus");
                    initialiseParticles      = Instantiate(particles[1], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Ice";
                }
                if (attackType == "LightningAttack")
                {
                    initialiseParticles      = Instantiate(particles[2], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Lightning";
                    attackEnemy.AddjustCurrentHealth(stored._attackValue[3], "minus");
                }

                playerAttack.attemptAttack = false;

                GameObject[] atemptingChange = GameObject.FindGameObjectsWithTag("PlayerBattle");
                obj[counter].transform.position = atemptingChange[counter].transform.position;

                BattleTimeScript batTimeScript = obj[counter].GetComponent <BattleTimeScript>();
                batTimeScript.timeToAttack1 = 0;

                animation.Play("idle");
            }
        }
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2");

        if (enemyObjects.Length != 0)
        {
            GameObject        constVar = GameObject.FindGameObjectWithTag("Constant");
            StoredInformation stored   = constVar.GetComponent <StoredInformation>();
            int counter = stored.BattlePosition;

            MagicAttack  pl;
            GameObject[] obj = GameObject.FindGameObjectsWithTag("Player2");
            pl = obj[counter].GetComponent <MagicAttack>();

            enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2");

            BattleAttackDisplay battleAttack = obj[counter].GetComponent <BattleAttackDisplay>();
            funTimes    = battleAttack.EnemyNumber;
            EnemyTarget = enemyObjects[funTimes];

            if (EnemyTarget == null)
            {
                EnemyTarget = enemyObjects[funTimes + 1];
            }

            if (attempt)
            {
                EnemyTarget = enemyObjects[funTimes];

                EnemyHealth attackEnemy = EnemyTarget.GetComponent <EnemyHealth>();
                attackType = battleAttack.attackType;
                if (attackType == "Fire")
                {
                    initialiseParticles      = Instantiate(particles[0], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Fire";

                    attackEnemy.AddjustCurrentHealth(stored._manaValue[0], "minus");
                }
                if (attackType == "Wind")
                {
                    initialiseParticles      = Instantiate(particles[1], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Wind";
                    attackEnemy.AddjustCurrentHealth(stored._manaValue[1], "minus");
                }
                if (attackType == "Ice")
                {
                    initialiseParticles      = Instantiate(particles[2], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Ice";

                    attackEnemy.AddjustCurrentHealth(stored._manaValue[2], "minus");
                }
                if (attackType == "Water")
                {
                    attackEnemy.AddjustCurrentHealth(stored._manaValue[3], "minus");
                    initialiseParticles      = Instantiate(particles[3], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Water";
                }
                if (attackType == "Lightning")
                {
                    initialiseParticles      = Instantiate(particles[4], EnemyTarget.transform.position, Quaternion.identity) as GameObject;
                    initialiseParticles.name = "Lightning";
                    attackEnemy.AddjustCurrentHealth(stored._manaValue[4], "minus");
                }


                pl.attempt = false;


                BattleTimeScript batTimeScript = obj[counter].GetComponent <BattleTimeScript>();
                batTimeScript.timeToAttack1 = 0;

                animation.Play("idle");
            }
        }
    }
 /// <summary>
 /// Start this instance.
 /// </summary>
 void Start()
 {
     desiredPlayer  =GameObject.FindGameObjectsWithTag("Player2");
     battle = desiredPlayer[0].GetComponent<BattleTimeScript>();
     constVar  =GameObject.FindGameObjectWithTag("Constant");
     stored = constVar.GetComponent<StoredInformation>();
     attacking = new PlayerAttack();
     attackingWithMagic = new MagicAttack();
 }