Esempio n. 1
0
 //no idea how to animate/do physics for this yet..
 private void transitionToAttacking()
 {
     currState     = EvilState.Attacking;
     queuedCommand = null;
     agent.enabled = true;
     agent.SetDestination(playerTransform.position);
     agent.speed = agent.speed * 2f;
 }
Esempio n. 2
0
    //he/she/it/they/Jabba's gender go through stunned stage and will look around afterwards
    private void transitionToStunned()
    {
        Debug.Log("Worked!!");
        currState     = EvilState.Stunned;
        queuedCommand = new Command(Vector3.zero, EvilState.Looking);

        agent.enabled = false;
        animator.Play(stunHash);
    }
Esempio n. 3
0
    //takes a command from the brain OR the player
    //does not directly set the transition, but the queued
    public void processCommand(Vector3 loc, EvilState order)
    {
        if (currState == EvilState.Attacking && order != EvilState.Stunned)
        {
            //do nothing, ignores everything when attacking EXCEPT when player stuns them

            return;
        }
        else
        {
            queuedCommand = new Command(loc, order);
        }
    }
Esempio n. 4
0
    //get random patrol point then go to it...
    private void transitionToPatrolling()
    {
        index    = Random.Range(0, patrolPoints.Length);
        patrolPt = patrolPoints[(int)index].transform.position;
        navDest  = new Vector3(patrolPt.x, 0, patrolPt.z);

        currState     = EvilState.Patrolling;
        queuedCommand = null;

        animator.Play(moveHash);

        agent.enabled = true;
        agent.SetDestination(navDest);
    }
Esempio n. 5
0
    // Start is called before the first frame update
    void Start()
    {
        agent           = GetComponent <NavMeshAgent>();
        player          = GameObject.FindWithTag("Player");
        playerTransform = player.transform;
        enemyTransform  = gameObject.transform;

        patrolPoints = GameObject.FindGameObjectsWithTag("PatrolPoint");
        currState    = EvilState.Looking;

        navDest = GameObject.Find("PP1").transform.position;
        agent.SetDestination(navDest);

        Random.InitState((int)Time.time);
    }
Esempio n. 6
0
    //if slist stunned, she will search when wake up, else they move to that location
    private void transitionToSeeking(Vector3 loc)
    {
        if (currState == EvilState.Stunned)
        {
            queuedCommand = new Command(loc, EvilState.Seeking);
        }
        else
        {
            currState     = EvilState.Seeking;
            navDest       = loc;
            agent.enabled = true;
            agent.SetDestination(loc);
            animator.Play(moveHash);

            queuedCommand = null;
        }
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        //agent.SetDestination(playerTransform.position);

        toPlayer  = playerTransform.position - enemyTransform.position;
        toNavDest = enemyTransform.position - navDest;

        //Debug.Log("dist to mark: " + Vector3.Magnitude(toNavDest));


        if (Vector3.Magnitude(toNavDest) < 1)
        {
            currState = EvilState.Looking;

            index = Random.Range(0, patrolPoints.Length);

            navDest = patrolPoints[(int)index].transform.position;
            agent.SetDestination(navDest);
        }



        float angle;

        //if (currState == EvilState.Looking){
        //keep turning around if havnt turned around full 180 degs
        //agent.isStopped = true;
        //........not sure how youd cleanly do this..

        //}



        /*if (currState == EvilState.Patrolling ||
         *   currState == EvilState.Looking ||
         *   currState == EvilState.Searching){
         *
         *   Debug.DrawRay(enemyTransform.position, toPlayer, Color.green, 1f);
         *
         *   if (Physics.Raycast(enemyTransform.position, toPlayer, out caster, Mathf.Infinity)){
         *
         *
         *
         *       if (caster.collider.CompareTag("Player")){
         *
         *           angle = Vector3.Angle(enemyTransform.forward, toPlayer);
         *
         *           if (angle < 30){
         *
         *               //Debug.Log("attacking...");
         *               //currState = EvilState.Leaping;
         *               agent.SetDestination(playerTransform.position);
         *
         *
         *               //do some stuff, maybe propel with force...
         *               //              maybe jack up the speed and set height
         *               //dk how to compromise between navagent and rigidbody..
         *
         *
         *               //also start keeping track of time...
         *               return;
         *           }
         *       }
         *   }
         * }*/



        /*there were problems here last time...
         * begin maybe irrelevant code
         * if (paused) {
         *  agent.Stop();
         * }
         *
         * //has to do with pausing I think...
         * if (just == 0){
         *  agent.SetDestination(this.transform.position);
         *  just = 1;
         *
         * }
         * else
         * {
         *  just = 0;
         *  agent.Resume();
         * }
         *///end perhaps irrelevant code....
    }
Esempio n. 8
0
    //slist sticks to the ceiling by disabling navmesh and moving
    //important bones in line with the angle of the face directly above...
    private void transitionToAmbush()
    {
        //animator.WriteDefaultValues();
        animator.enabled = false;
        agent.enabled    = false;

        currState = EvilState.Ambush;

        //straighten out
        transform.Rotate(new Vector3(90, 0, 0));
        transform.position += Vector3.up;

        int i    = 0;
        int mask = ~(1 << 9);

        float boneAngle;

        Transform animRoot = transform.Find("Armature").Find("Root");

        ArrayList angles = new ArrayList(), points = new ArrayList(), bones;

        Queue <Transform> animQ = new Queue <Transform>();

        animQ.Enqueue(animRoot);
        bones = traverseAnimTree(animQ);

        Vector3 crossProd;

        foreach (Transform bone in bones)
        {
            Physics.Raycast(bone.position, Vector3.up, out caster, 20, mask);
            angles.Add(caster.normal);
            points.Add(caster.point);
        }


        foreach (Transform bone in bones)
        {
            Debug.Log("transforming bone: " + bone.gameObject.name);

            bone.position = (Vector3)points[i];
            crossProd     = Vector3.Cross((Vector3)angles[i], bone.forward);

            boneAngle = Vector3.SignedAngle(bone.forward, (Vector3)angles[i], crossProd);

            if (bone.gameObject.name.Equals("Thigh.R"))
            {
                Debug.DrawRay(bone.position, 2 * bone.forward, Color.blue, 160);
                Debug.DrawRay(bone.position, 2 * crossProd, Color.red, 160);
                Debug.DrawRay(bone.position, 2 * (Vector3)angles[i], Color.green, 160);
            }

            bone.Rotate(crossProd, boneAngle, Space.World);

            if (bone.gameObject.name.Equals("Thigh.R"))
            {
                Debug.DrawRay(bone.position, 2 * bone.forward, Color.yellow, 160);
            }

            ++i;
        }
    }
Esempio n. 9
0
 //used after slist stunned, she looks around for a bit (dk if should)
 //no queued command specified, they will look around then patrol by default,
 //unless the brain or player sends a command
 private void transitionToLooking()
 {
     currState = EvilState.Looking;
     animator.Play(lookHash);
 }
Esempio n. 10
0
 public Command(Vector3 ploc, EvilState paction)
 {
     loc    = ploc;
     action = paction;
 }