Exemplo n.º 1
0
	// Use this for initialization
	void Start () {
        shootingCooldownTimer = 0f;
        if (!goodSoldiers)
        {
            goodSoldiers = GameObject.Find("GoodSoldiers").transform;
        }
        healthScript = transform.GetComponent<SoldierHealthManager>();
	}
    void Attack(Transform target, SoldierHealthManager targetHealth)
    {
        if (targetHealth)
        {
            targetHealth.TakeDamage(healthScript.damage - targetHealth.armor);
            healthScript.TakeDamage(targetHealth.damage - healthScript.armor);
        }

        shootTimer = 0;
    }
    // Use this for initialization
    void Start()
    {
        //  transform.position = new Vector3(10, 0, 10);
        navAgent = this.GetComponent <NavMeshAgent>();
        if (!Destination)
        {
            Destination = GameObject.Find("Train").transform;
        }

        //   Destination = GameObject.Find("Scaler").transform.Find("Train");
        //navAgent.destination = Destination.position;
        healthScript = GetComponent <SoldierHealthManager>();

        attackTarget             = false;
        constantlyCheckTargetPos = true;
        enemyChecktimer          = 0;
        shootTimer = 0;
    }
    void CheckForEnemies()
    {
        Debug.Log("Calling CheckForEnemies from: " + name);

        if (enemySoldiers.childCount > 0)
        {
            targetHealth = enemySoldiers.GetChild(0).GetComponent <SoldierHealthManager>();
            foreach (Transform child in enemySoldiers)
            {
                if (Vector3.Distance(child.position, transform.position) < (GetComponent <MeshRenderer>().bounds.size.x *10))
                {
                    targetHealth = child.GetComponent <SoldierHealthManager>();
                    //Stop
                    navAgent.Stop();
                    child.GetComponent <NavMeshAgent>().Stop();
                    //Fight
                    target       = child;
                    attackTarget = true;
                }
            }
        }
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        castle             = GameObject.Find("Scaler").transform.Find("Village").Find("Castle");
        hills              = GameObject.Find("Scaler").transform.Find("TerrainObjects").Find("Hills");
        minesManagerScript = GameObject.Find("Scaler").transform.Find("Mines").Find("PlayerMines").GetComponent <PlayerMinesController>();
        minerCanvas        = transform.Find("Canvas");
        //  transform.position = new Vector3(10, 0, 10);
        navAgent = this.GetComponent <NavMeshAgent>();
        if (isAssignedToAMine)
        {
            AssignToMine(assignedMine);
        }
        else
        {
            minerCanvas.Find("ExplorePanel").gameObject.SetActive(true); //Await input
            if (hills.childCount > 0)
            {
                //Nothing needed?
            }
            else
            {
                Debug.Log("Error: miner nav cannot go to any hills because there are none listed");
            }

            /*   SetMineZone(hills.GetChild(0));
             * if(hills.GetChild(0).childCount > 0)
             * {
             *     SearchForNextMine();
             * }*/
        }

        //   Destination = GameObject.Find("Scaler").transform.Find("Train");
        //navAgent.destination = Destination.position;
        healthScript       = GetComponent <SoldierHealthManager>();
        miningTimer        = 0;
        indexOfMineSearch  = 0;
        miningTimerOn      = false;
        reachedDestination = false;
    }
 // Use this for initialization
 void Start()
 {
     attacking = true;
     attackingEnemySoldiers = false;
     moving        = true;
     targetsNearby = false;
     gunFireTimer  = 0;
     if (soldierRunSpeed == 0)
     {
         soldierRunSpeed = 10;
     }
     if (!tracks)
     {
         tracks = GameObject.Find("Tracks").transform;
     }
     if (!enemySoldiers)
     {
         enemySoldiers = GameObject.Find("TrainCart").transform.Find("Soldiers").transform;
     }
     healthScript  = transform.GetComponent <SoldierHealthManager>();
     soldierDamage = healthScript.GetDamageStrength();
     sounds        = GetComponents <AudioSource>();
 }
    void Start()
    {
        prefabHealthScript  = goodSoldierPrefab.GetComponent <SoldierHealthManager>();
        spawnSpot           = transform.Find("SpawnSpot");
        barracksQueuePanel  = transform.Find("Canvas").Find("RotationPanel").Find("QueuePanel");
        currentLevelInQueue = currentPosInLevel = 0;
        nextSpriteInQueue   = barracksQueuePanel.GetChild(currentLevelInQueue).GetChild(currentPosInLevel);

        barracksStatusPanel    = barracksQueuePanel.parent.parent.Find("BarracksStatusPanel");
        barracksSelectionPanel = barracksQueuePanel.parent.Find("UnitSelectionPanel");
        rotationPanel          = barracksQueuePanel.parent;
        queueFull    = false;
        queueEmpty   = true;
        queueTimerOn = false;
        rotating     = false;
        queueTimer   = 0;
        startX       = 0;


        UpdateSoldierCostText();
        UpdateUpgradeAttackTexts();
        UpdateUpgradeArmorTexts();
    }