Beispiel #1
0
    /**Find rodents whove been teleported */
    private List <GameObject> findfromCached()
    {
        // Debug.Log("Finding from Cached");
        List <GameObject> chosen = new List <GameObject>();

        //Get the player
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        chosen.Add(player);

        //get the royal guard
        PlayerStats ps = player.GetComponent <PlayerStats>();

        if (ps)
        {
            foreach (var e in ps.getEmployees())
            {
                chosen.Add(e);
                //everytime we teleport clear previous targets and go back to royal guarding
                Rodent r = e.GetComponent <Rodent>();
                if (r)
                {
                    var ss = e.GetComponent <SubjectScript>();
                    if (ss)
                    {
                        ss.setRoyalGuard();
                    }
                }
            }
        }

        //get the previously teleported troops
        foreach (Rodent child in _TeleportDummy.GetComponentsInChildren <Rodent>())
        {
            chosen.Add(child.gameObject);
            //put them back in heirarchy
            child.transform.SetParent(GameObject.FindGameObjectWithTag("PlayerRodents").transform);
        }

        //If were coming back from the neutral zone to player zone
        if ((_zone == 2 && !_isRightZone) || (_zone == 3 && _isRightZone))
        {
            //Reset the rodents to go back to the outpost
            foreach (BuildableObject b in _outposts)
            {
                List <GameObject> workers = b.getEmployees();
                foreach (var go in workers)
                {
                    //b.AssignWorker(go.GetComponent<Rodent>());
                    Rodent r = go.GetComponent <Rodent>();
                    if (r)
                    {
                        r.setTarget(b.gameObject); // setting target will reset them back to outpost duties
                    }
                }
            }
        }
        _TroopLocations.Clear();
        return(chosen);
    }
Beispiel #2
0
 public void Dismiss(Rodent r)
 {
     if (r == null)
     {
         return;
     }
     // Debug.Log("heard Dismiss Employee :" + r.getName());
     if (_Occupied)
     {
         if (_currentRodent && _currentRodent == r)
         {
             _currentRodent.setTarget(null);
             _PortraitOutline.GetComponent <bWorkerScript>().setWorker(null);
             _WorkerObj.GetComponent <SpriteRenderer>().sprite = null;
             //print("dismiss");
             _Occupied      = false;
             _currentRodent = null;
             ShowRedX(false);
             UIAssignmentMenu.Instance.ResetButtons();
             ShowWeaponClass(false);
             //unsubscribe - unused now
             //EventSystem.Instance.rodentDead -= Dismiss;
             SoundManager.Instance.PlayDismiss();
             r.ShowDismissMenu(false);
         }
     }
 }
    public void AssignWorker(Rodent r)
    {
        // Debug.Log("AssignWorker!" + r.getName() + "to " + this.gameObject);
        // print("USed Slots =" + ResourceManagerScript.Instance.getNoBuildingSlots());
        //print("Max cap = " + GameManager.Instance.GetBuildingCap());
        if (eType == BuildingType.Vacant)
        {
            return;
        }

        bool okayToAdd = true;
        int  index     = findAvailableSlot();

        if (index > -1)         //This is kind of a hack
        {
            if (ResourceManagerScript.Instance.getNoBuildingSlots() >= GameManager.Instance.GetBuildingCap())
            {
                if (eType == BuildingType.GarbageCan || eType == BuildingType.WoodPile || eType == BuildingType.StonePile)
                {
                    okayToAdd = false;
                    //print("not okay to add  type:" + eType);
                }
            }

            if (okayToAdd)
            {
                //print("okay to add");
                _Workers[index].Assign(r);
                r.setTarget(this.gameObject);

                //Start Construction or Gathering
                if (eState == BuildingState.Building)
                {
                    // if (getEmployeeCount() != 0)
                    //     StartCoroutine(BeginConstructionLoop());
                }
                else if (eState == BuildingState.Built && eType == BuildingType.Farm || eType == BuildingType.GarbageCan || eType == BuildingType.WoodPile || eType == BuildingType.StonePile)
                {
                    if (getEmployeeCount() != 0)
                    {
                        //StartCoroutine(BeginSearchLoop());   //Old wya to auto do
                    }
                    if (eType != BuildingType.Farm)
                    {
                        if (ResourceManagerScript.Instance.getNoBuildingSlots() < GameManager.Instance.GetBuildingCap())
                        {
                            //Add to our building cap
                            ResourceManagerScript.Instance.IncrementBuildingSlots(1);
                        }
                    }
                }
            }
        }
    }
Beispiel #4
0
    public void AssignWorker(Rodent r)
    {
        //Debug.Log("AssignWorker!" + r.getName());

        int index = findAvailableSlot();

        if (index > -1)         //This is kind of a hack
        {
            _RoyalGuards[index].Assign(r);
            r.setTarget(this.gameObject);
        }
        //  else
        //  Debug.Log("no Empty");
    }