public virtual void CreateFighter() { if (FoodAmount >= fighterCost) { FoodAmount = -fighterCost; fighters++; NewGameController.Instance.TeamSize[teamID] += 1; if (FighterPool.Count > 0) { FighterController recycle = FighterPool.Find(f => !f.isActive); if (recycle != null) { recycle.SetMoM(this.gameObject); recycle.transform.position = Location + new Vector3(1, 0, 1); } else { InstantiateFighter(); } } else { InstantiateFighter(); } } }
protected void InstantiateFighter() { GameObject spawn = Instantiate(fighterFab, SpawnMouth, FaceForward) as GameObject; FighterController fc = spawn.GetComponent <FighterController>(); NetworkServer.Spawn(spawn); fc.SetMoM(this.gameObject); FighterPool.Add(fc); }