示例#1
0
    void Start()
    {
        agent       = this.GetComponent <NavMeshAgent>();
        agent.speed = speed;

        if (team1)
        {
            //Creating a list of path points
            pathPoints = GameObject.FindGameObjectsWithTag("Player1MobPoint");
            pathPoints = pathPoints.OrderBy(point => Vector3.Distance(this.transform.position, point.transform.position)).ToArray();

            //Set Values
            armoury = GameObject.FindGameObjectWithTag("Armoury").GetComponent <Armoury>();
            damage  = armoury.GetRangedDMG();
            hp      = armoury.GetRangedHP();
            targetLogic.SetDMG(damage);
            targetLogic.SetTeam(team1);
        }
        else
        {
            pathPoints   = GameObject.FindGameObjectsWithTag("Castle");
            pathPoints   = pathPoints.OrderBy(point => Vector3.Distance(this.transform.position, point.transform.position)).ToArray();
            currentPoint = 1;
            enemyManager = GameObject.FindGameObjectWithTag("EnemyManager").GetComponent <EnemyManager>();
            damage       = enemyManager.GetRangedDamage();
            hp           = enemyManager.GetRangedHP();
            targetLogic.SetDMG(damage);
        }

        //Setting UI
        dmgTXT.text = damage.ToString();
        hpTXT.text  = hp.ToString();
    }
示例#2
0
 void Awake()
 {
     armoury     = gameObject.GetComponent <Armoury> ();
     playerIndex = gameObject.GetComponent <PlayerIndex> ();
     roster      = gameObject.GetComponent <Roster> ();
     sceneLoader = gameObject.GetComponent <SceneLoader> ();
     scoreboard  = gameObject.GetComponent <Scoreboard> ();
     soundPlayer = gameObject.GetComponent <SoundPlayer> ();
 }
示例#3
0
        public CollectableGun(SceneManager mSceneMgr, Gun gun, Armoury playerArmoury)
        {
            // Initialize here the mSceneMgr, the gun and the playerArmoury fields to the values passed as parameters

            // Initialize the gameNode here, scale it by 1.5f using the Scale funtion, and add as its child the gameNode contained in the Gun object.
            // Finally attach the gameNode to the sceneGraph.

               // Here goes the link to the physics engine
               // (ignore until week 8) ...
        }
示例#4
0
    void Upgrade()
    {
        Armoury script = armoury.GetComponent <Armoury>();

        if (isMelee && upgradeDMG && melee_DMG_price < resources.GetGold())
        {
            resources.RemoveGold(melee_DMG_price);
            script.AddMeleeDMG(5);
            melee_DMG_price += 5;
            upgradeTXT.text  = melee_DMG_price.ToString();
        }

        else if (!isMelee && upgradeDMG && ranged_DMG_price < resources.GetGold())
        {
            resources.RemoveGold(ranged_DMG_price);
            script.AddRangedDMG(5);
            ranged_DMG_price += 5;
            upgradeTXT.text   = ranged_DMG_price.ToString();
        }

        else if (isMelee && !upgradeDMG && melee_HP_price < resources.GetGold())
        {
            resources.RemoveGold(melee_HP_price);
            script.AddMeleeHP(5);
            melee_HP_price += 5;
            upgradeTXT.text = melee_HP_price.ToString();
        }
        else if (!isMelee && !upgradeDMG && ranged_HP_price < resources.GetGold())
        {
            resources.RemoveGold(ranged_HP_price);
            script.AddRangedHP(5);
            ranged_HP_price += 5;
            upgradeTXT.text  = ranged_HP_price.ToString();
        }

        print("unit upgraded");
    }