Exemplo n.º 1
0
    //Have to do a delay otherwise subject script settings get really messed up
    IEnumerator attackerDelay(GameObject o)
    {
        yield return(new WaitForSeconds(0.8f));

        SubjectScript s = this.GetComponent <SubjectScript>();

        if (s)
        {
            s.changeTarget(o);
        }

        s.setAttacker();
        _Status = eStatus.Army;
    }
Exemplo n.º 2
0
    /** Responsible for giving SubjectScript new Target and Updating our Status  */
    public void setTarget(GameObject o)
    {
        //print("set Target called");

        _placeOfWork = o;
        //need proper getter/setter someday
        SubjectScript s = this.GetComponent <SubjectScript>();

        if (s)
        {
            s.changeTarget(o);
        }

        if (o == null)
        {
            _Status = eStatus.Available;
            s.setIdle();
            //Show the Exclamation for available non enemy rodents
            if (_Team != 2)
            {
                _NotificationObject.SetActive(true);
                _NotifyAnimator.SetBool("Notify", true);
            }
            return;
        }


        if (o.GetComponent <BuildableObject>())
        {
            BuildableObject bo = o.GetComponent <BuildableObject>();
            if (bo.getState() == BuildableObject.BuildingState.Building)
            {
                //Tell subject script to behave like a builder
                s.setBuilder();
                _Status = eStatus.Building;

                _NotificationObject.SetActive(false);
                // Debug.Log("Updated State to Builder");
                //OR
                // Tell them to defend a location when that script arrives
                // _Status = eStatus.Army;
            }
            else if (bo.getState() == BuildableObject.BuildingState.Built || bo.getState() == BuildableObject.BuildingState.Idle)
            {
                //Unknown if state IDLE could cause a unique problem, can a building be
                // idle but not built? i forget
                _NotificationObject.SetActive(false);

                // Tell Subject Script to behave like a Worker
                if (bo.getType() == BuildableObject.BuildingType.Outpost)
                {
                    _Status = eStatus.Army; // for all intensive purposes army can behave same for player and defense structure
                    s.setDefender();
                    // print("Told to be defender");
                }
                else if (bo.getType() == BuildableObject.BuildingType.Farm)
                {
                    _Status = eStatus.Working;
                    s.setFarmer();
                }
                else
                {
                    _Status = eStatus.Working;
                    s.setGatherer();
                }
            }
        }
        else if (o.GetComponent <PlayerStats>())
        {
            //Debug.Log("Was told to go to RoyalGuard");
            // Tell Subject script to behave like a bodyguard
            _NotificationObject.SetActive(false);
            s.setRoyalGuard();
            _Status = eStatus.Army; // for all intensive purposes army can behave same for player and defense structure
        }
        else
        {
            Debug.Log("We dont know this behavior");
            s.setIdle();
        }
    }