/*
     * Set the soldier to be visible or not.
     */
    void ChangeVisibility(Collider collisionInfo, bool visibility)
    {
        GameCharacterModel soldierScript =
            collisionInfo.gameObject.GetComponent <
                GameCharacterModel>();

        soldierScript.Visible = visibility;
    }
    void OnTriggerEnter(Collider collisionInfo)
    {
        GameCharacterModel target =
            collisionInfo.gameObject.GetComponent <GameCharacterModel>();

        if (target)
        {
            target.ApplyDamage(damage, 0.0f);
        }

        Destroy(gameObject);
    }
    /*
     * Get the stats of the most recently selected squad to display in the
     * GUI.
     */
    void GetSquadStats(GameObject squad)
    {
        GameObject newSquad = (GameObject)Instantiate(
            squad, new Vector3(-50.0f, -200.0f, 0.0f),
            Quaternion.identity);
        GameCharacterModel soldierScript = newSquad.GetComponent <
            GameCharacterModel>();

        squadDefense = soldierScript.BaseDefense;
        squadHealth  = soldierScript.MaxHealth;
        squadSize    = soldierScript.SquadSize;
        squadSpeed   = soldierScript.BaseSpeed;
        squadName    = soldierScript.SoldierName;
        Destroy(newSquad);
    }
    /*
     * Spawn all the soldiers in a particular squad.
     */
    IEnumerator SpawnSquad(GameObject squad, int squadNum)
    {
        GameCharacterModel soldierScript =
            squad.GetComponent <GameCharacterModel>();
        int soldiersSpawned = 0;

        while (soldiersSpawned < soldierScript.SquadSize)
        {
            Vector3 startPos = spawnTransform.position;
            startPos.y = startPos.y + squad.transform.lossyScale.y;
            GameObject newSoldier = (GameObject)Instantiate(
                squad, startPos, Quaternion.identity);
            GameCharacterModel newSoldierScript =
                newSoldier.GetComponent <GameCharacterModel>();
            newSoldierScript.SquadNumber = squadNum;
            yield return(StartCoroutine(newSoldierScript.Start()));

            soldiersSpawned++;
            soldiersDeployed++;
            yield return(new WaitForSeconds(newSoldierScript.SpawnDelay));
        }
    }
 void OnTriggerEnter(Collider collisionInfo)
 {
     if (collisionInfo.gameObject.layer ==
         LayerMask.NameToLayer("Soldiers"))
     {
         // Apply regular damage
         GameCharacterModel soldierScript =
             collisionInfo.gameObject.GetComponent <
                 GameCharacterModel>();
         soldierScript.ApplyDamage(damage, piercingDmg);
         // Apply area of effect damage
         if (areaOfEffect > 0.0f)
         {
             Collider[] hits = Physics.OverlapSphere(
                 thisTransform.position, areaOfEffect,
                 1 << LayerMask.NameToLayer("Soldiers"));
             foreach (Collider soldier in hits)
             {
                 soldier.transform.gameObject.GetComponent <
                     GameCharacterModel>().ApplyDamage(
                     areaOfEffectDamage);
             }
         }
         // Apply damage over time effect
         if (dmgOverTimeDuration > 0)
         {
             soldierScript.ApplyDamage(dmgOverTime, dmgOverTimeDuration);
         }
         // Apply slow effect
         if (slowMagnitude > 0.0f)
         {
             soldierScript.Slow(slowMagnitude, slowDuration);
         }
         Destroy(gameObject, 0.1f);
     }
 }
 void Start()
 {
     statsScript = GetComponent <GameCharacterModel>();
 }