コード例 #1
0
        public Waypoint AssignToWaypoint()
        {
            Waypoint home = new GetClosestWaypoint().search(this.transform.position);

            if (thisunit.faction == "Player")
            {
                home.Allies.Add(this.gameObject);
            }
            if (thisunit.faction == "Enemy")
            {
                home.Enemies.Add(this.gameObject);
            }
            return(home);
        }
コード例 #2
0
        //This function is a total mess and needs some polish and refactoring - but it works just well enough :D
        //This works like a hobbled together foreach loop, going backwards in selected.
        IEnumerator SetupLine(GameObject node, bool firstloop)
        {
            float randomizedTiming = Random.Range(0.2f, 0.3f);

            if (firstloop)
            {
                yield return(new WaitUntil(() => firstloop == true));
            }
            else
            {
                yield return(new WaitForSeconds(randomizedTiming));
            }


            if (selected.Count > 0)
            {
                GameObject troop     = selected[selected.Count - 1];
                Waypoint   oldHome   = new GetClosestWaypoint().search(troop.transform.position);
                Waypoint   newHome   = node.GetComponent <Waypoint>();
                Unit       troopInfo = troop.GetComponent <UnitCore>().thisunit;
                troop.GetComponent <Outline>().enabled     = false;
                troop.GetComponent <UnitCore>().isSelected = false;

                if (oldHome != newHome)
                {
                    if (troopInfo.faction == "Player")
                    {
                        oldHome.AllyRemove(troop);
                        newHome.AllyAdd(troop);
                        troop.GetComponent <Movement>().MoveTo(newHome, "Right", newHome.Allies.Count, true);
                    }

                    if (troopInfo.faction == "Enemy")
                    {
                        oldHome.EnemyRemove(troop);
                        newHome.EnemyAdd(troop);
                        troop.GetComponent <Movement>().MoveTo(newHome, "Left", newHome.Enemies.Count, true);
                    }
                }
                if (selected.Count == 1)
                {
                    selected.RemoveAt(selected.Count - 1);
                }
                else
                {
                    selected.RemoveAt(selected.Count - 1);
                    StartCoroutine(SetupLine(node, false));
                }
            }
        }
コード例 #3
0
 //Removes this unit from play
 public void death()
 {
     if (this.gameObject != null)
     {
         Waypoint home = new GetClosestWaypoint().search(this.transform.position);
         if (thisunit.faction == "Player")
         {
             home.Allies.Remove(this.gameObject);
         }
         if (thisunit.faction == "Enemy")
         {
             home.Enemies.Remove(this.gameObject);
         }
         Destroy(GeneratedUI);
         PS.Play();
         isDead = true;
         StartCoroutine(DeleteObject());
         StartCoroutine(StopParticles());
         StartCoroutine(FadeTo(0.0f, 1.0f));
     }
 }