示例#1
0
 public bool checkSelected()
 {
     if (eType == BuildingType.Outpost)
     {
         bOutpost outpost = GetComponent <bOutpost>();
         return(!outpost.getSelected());  // logic is backwards somewhere w the negation sign but this works
     }
     else
     {
         Debug.LogWarning("its not an outpost?");
     }
     return(false);
 }
示例#2
0
 public void setOutlineSelected()
 {
     if (eType == BuildingType.Outpost)
     {
         SpriteRenderer sr = GetComponent <SpriteRenderer>();
         if (sr)
         {
             bOutpost outpost = GetComponent <bOutpost>();
             var      s       = outpost.getSelected(_level);
             sr.sprite = s;
             outpost.setSelected(false);
         }
     }
 }
示例#3
0
    // used to be from MVC controller to let the building know its been clicked
    public void imClicked()
    {
        if (_Team == 2)
        {
            return;
        }
        // Debug.Log("Building is Clicked state is" + eState);
        if (eState == BuildingState.Built)
        {
            //Create a new menu interaction on a built object, downgrade? Demolish? Show resource output etc. Needs Something
            if (eType == BuildingType.GarbageCan || eType == BuildingType.WoodPile || eType == BuildingType.StonePile)
            {
                if (getEmployeeCount() == 0) // if someone is working here, player cant gather
                {
                    //Debug.Log("I am gathering!");
                    Searchable s = GetComponent <Searchable>();
                    if (s)
                    {
                        // s.GatherAction(20);
                        s.ImClicked(); // should use ImClicked instead of GatherAction and encapsulate gather action into searchables functionality
                    }
                }
            }
            else if (eType == BuildingType.Outpost && _cameraController.getOverrideMode())
            {
                bOutpost outpost = GetComponent <bOutpost>();
                if (outpost.getSelected())
                {
                    setOutlineSelected();
                    UITroopSelection.Instance.addTroops(getEmployeeCount());
                }
                else
                {
                    setOutlineAvailable();
                    UITroopSelection.Instance.addTroops(0 - getEmployeeCount());
                }
            }
            else
            {
                StartCoroutine(ClickDelay(true, _DestroyMenu));
                StartCoroutine(ClickDelay(false, _BuildMenu));
                StartCoroutine(ClickDelay(false, _BuildingCapMenu));
            }
        }
        else if (eState == BuildingState.Available || eState == BuildingState.Idle)
        {
            // Turns off the "notification exclamation mark" as the player is now aware of obj
            eState = BuildingState.Idle;

            //check if we can afford a building slot
            if (ResourceManagerScript.Instance.getNoBuildingSlots() < GameManager.Instance.GetBuildingCap())
            {
                StartCoroutine(ClickDelay(true, _BuildMenu));
            }
            else
            {
                //TO-DO: Show new menu that tells player at cap and to upgrade TC
                StartCoroutine(ClickDelay(true, _BuildingCapMenu));
            }
            StartCoroutine(ClickDelay(false, _DestroyMenu));

            //Disconnect here, MVC controller is now responsible for talking to UI
        }
        else if (eState == BuildingState.Building)
        {
            //IncrementConstruction(1);
            //Show a menu that asks to spend a shiny to increment
            _InstanceConstructionButton.SetActive(true);
            MVCController.Instance.setLastInstantConstruction(_InstanceConstructionButton);
        }

        if (!_cameraController.getOverrideMode())
        {
            UpdateState();
        }
    }