Beispiel #1
0
    private bool Look(StateController controller)
    {
        //RaycastHit hit;

        /// Will draw a green line in front of where this is looking.
        Debug.DrawRay(controller.eyes.position, controller.eyes.forward.normalized * controller.enemyStats.lookRange, Color.green);

        Target target = FindObjectOfType <Target>();

        //Target target = TargetsAndArrayList.GetNearestInArrayList().GetComponent<Target>();

        //if (target.isActiveAndEnabled) {
        //if (target != null) {
        //if (TargetsAndArrayList.GetNearestInArrayList().GetComponent<Target>() != null) {
        if (TargetsAndArrayList.CountThingsInArrayList() != 0)
        {
            //if (target != null && TargetsAndArrayList.CountThingsInArrayList() != 0) {
            if (TargetsAndArrayList.GetNearestInArrayList().activeSelf)
            {
                //controller.chaseTarget = target.transform;
                controller.chaseTarget = TargetsAndArrayList.GetNearestInArrayList().GetComponent <Target>().transform;
                Debug.Log("Inside LookDecision1.Look()");
                Debug.Log("controller.chaseTarget = " + controller.chaseTarget);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
    //// Use this for initialization
    //void Start () {

    //}

    //// Update is called once per frame
    //void Update () {

    //}

    public override bool Decide(StateController controller)
    {
        //bool chaseTargetIsActive = controller.chaseTarget.gameObject.activeSelf;
        //bool chaseTargetIsActive = FindObjectOfType<Target>().gameObject.activeSelf;
        //if (FindObjectOfType<Target>().gameObject.activeSelf != null) {
        //if (FindObjectOfType<Target>()) {
        //    TargetsAndArrayList.CountThingsInArrayList();
        //    Debug.Log("Inside ActiveStateDecision1.Decide()");
        //    Debug.Log("FindObjectOfType<Target>().name = " + FindObjectOfType<Target>().name);
        //    return true;
        //} else {
        //    return false;
        //}

        //bool chaseTargetIsActive = TargetsAndArrayList.GetNearestInArrayList().activeSelf;
        //return chaseTargetIsActive;

        bool chaseTargetIsActive = TargetsAndArrayList.GetNearestInArrayList().activeSelf;

        //bool chaseTargetIsActive = controller.chaseTarget.gameObject.activeSelf;
        //if (chaseTargetIsActive) {
        //Target target = FindObjectOfType<Target>();
        //if (target != null && TargetsAndArrayList.CountThingsInArrayList() != 0 && chaseTargetIsActive) {
        if (chaseTargetIsActive)
        {
            //Debug.Log(TargetsAndArrayList.CountThingsInArrayList());
            Debug.Log("Inside ActiveStateDecision1.Decide() \n TargetsAndArrayList.GetNearestInArrayList().name = " + TargetsAndArrayList.GetNearestInArrayList().name);
            return(true);
        }
        else
        {
            return(false);
        }
    }
        private void OnEnable()
        {
            // When the tank is enabled, reset the tank's health and whether or not it's dead.
            m_CurrentHealth = m_StartingHealth;
            m_Dead          = false;

            // Update the health slider's value and color.
            SetHealthUI();

            Debug.Log("this.gameObject.name = " + this.gameObject.name);
            TargetsAndArrayList.AddToArrayList(this.gameObject);
        }