Exemplo n.º 1
0
    public int canSeePlayer()
    {
        // 0 = cant see him
        // 1 = player spotted
        // 2 = investigate
        // 3 = opticform
        int state = 0;

        foreach(RaycastHit hit in hits)
        {
            if(hit.transform && hit.transform.tag == "Player")
            {
                if(Vector3.Distance(hit.transform.position, transform.parent.position) <= spotRange)
                {
                    state = 1;
                    alert = alertState.kill;
                }
                else
                {
                    state = 2;
                    alert = alertState.investigate;
                }
                break;
            }
            else if (hit.transform && hit.transform.tag == "OpticForm")
            {
                state = 3;
                alert = alertState.investigate;
            }
        }

        return state;
    }
Exemplo n.º 2
0
 private void Awake()
 {
     alertState   = new alertState(this);
     attackState  = new attackState(this);
     patrolState  = new patrolState(this);
     chaseState   = new chaseState(this);
     navMeshAgent = GetComponent <NavMeshAgent>();
 }
Exemplo n.º 3
0
    void ActivateAlert(alertState alertState)
    {
        switch (alertState)
        {
        case alertState.subs:

            subscription.Root.SetActive(true);
            follower.Root.SetActive(false);
            donation.Root.SetActive(false);
            host.Root.SetActive(false);
            subscription._3DLayer.SetActive(true);
            follower._3DLayer.SetActive(false);
            donation._3DLayer.SetActive(false);
            host._3DLayer.SetActive(false);

            subscription.User.text       = eventData.datas.items[0].parameters.username;
            subscription.Message.text    = eventData.datas.items[0].parameters.message;
            subscription.ResubCount.text = "Resub " + eventData.datas.items[0].parameters.resub + "x";
            Debug.Log("Subscription");
            break;

        case alertState.follow:

            subscription.Root.SetActive(false);
            follower.Root.SetActive(true);
            donation.Root.SetActive(false);
            host.Root.SetActive(false);
            subscription._3DLayer.SetActive(false);
            follower._3DLayer.SetActive(true);
            donation._3DLayer.SetActive(false);
            host._3DLayer.SetActive(false);

            follower.User.text = eventData.datas.items[0].parameters.username;
            Debug.Log("Follower");
            break;

        case alertState.donation:

            subscription.Root.SetActive(false);
            follower.Root.SetActive(false);
            donation.Root.SetActive(true);
            host.Root.SetActive(false);
            subscription._3DLayer.SetActive(false);
            follower._3DLayer.SetActive(false);
            donation._3DLayer.SetActive(true);
            host._3DLayer.SetActive(false);

            donation.User.text    = eventData.datas.items[0].parameters.username;
            donation.Amount.text  = eventData.datas.items[0].parameters.amount + eventData.datas.items[0].parameters.currency;
            donation.Message.text = eventData.datas.items[0].parameters.message;
            Debug.Log("Donation");
            break;

        case alertState.host:

            subscription.Root.SetActive(false);
            follower.Root.SetActive(false);
            donation.Root.SetActive(false);
            host.Root.SetActive(true);
            subscription._3DLayer.SetActive(false);
            follower._3DLayer.SetActive(false);
            donation._3DLayer.SetActive(false);
            host._3DLayer.SetActive(true);

            host.User.text = eventData.datas.items[0].parameters.username;
            Debug.Log("Host");
            break;

        default:
            break;
        }
    }