예제 #1
0
    public bool interact(NPCroutine npc)
    {
        if (disableInteract)
        {
            return(false);
        }

        if (npc.ownKey)
        {
            if (locked)
            {
                detector.enabled = true;
                locked           = false;
                lockSignal.GetComponent <MeshRenderer>().material = unlockedMat;
            }
            else
            {
                gate.transform.position = gameObject.transform.position;
                detector.enabled        = false;
                locked = true;
                lockSignal.GetComponent <MeshRenderer>().material = lockedMat;
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #2
0
    IEnumerator getKeyRoutine()
    {
        stdWalk = false;
        NPCroutine myRoutine = gameObject.GetComponent <NPCroutine>();

        _agent.speed = 10;
        yield return(StartCoroutine(npc.goToLocator(l2.gameObject, npc)));

        yield return(StartCoroutine(npc.goToLocator(l3.gameObject, npc)));

        while (!npc.ownKey)
        {
            npc.matInteract(mat1);
            yield return(new WaitForSeconds(0.2f));
        }

        yield return(StartCoroutine(npc.goToLocator(l2.gameObject, npc)));

        yield return(StartCoroutine(npc.goToLocator(l1.gameObject, npc)));

        npc.matInteract(mat2);
        npc.Vspeed = 5;
        stdWalk    = true;
        yield return(null);
    }
 // Use this for initialization
 void Start()
 {
     npc = GetComponent <NPCroutine>();
     //StartCoroutine(fixedRoutine());
     cellDoor.disableInteract = true;
     StartCoroutine(starterRoutine());
 }
 public bool interact(NPCroutine npc)
 {
     if (disableInteract)
     {
         return(false);
     }
     //going to pretend that it's like gaurd 3 has a unique key for this door, but really he's the only one who can unlock it
     if (npc.GetComponent <NPCgaurd3script>() != null)
     {
         if (locked)
         {
             detector.enabled = true;
             locked           = false;
             lockSignal.GetComponent <MeshRenderer>().material = unlockedMat;
         }
         else
         {
             gate.transform.position = gameObject.transform.position;
             detector.enabled        = false;
             locked = true;
             lockSignal.GetComponent <MeshRenderer>().material = lockedMat;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #5
0
    public IEnumerator breakout()
    {
        haveTarget       = false;
        stdWalk          = false;
        npc._agent.speed = 10;
        NPCroutine myRoutine = gameObject.GetComponent <NPCroutine>();

        yield return(StartCoroutine(myRoutine.goToLocator(breakoutTarget, npc)));

        StartCoroutine(breakoutTarget.GetComponent <NPCroutine>().handcuffTo(npc.gameObject));
        haveTarget = true;
        while (!gaurd1.GetComponent <NPCgaurd1script>().haveTarget)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        while (!gaurd3.GetComponent <NPCgaurd3script>().haveTarget)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        if (myRoutine.ownKey)
        {
            //i have the key
            yield return(StartCoroutine(myRoutine.goToLocator(innerCellLocator1, npc)));

            if (topDoor.locked)
            {
                topDoor.interact(npc);
            }
            yield return(StartCoroutine(myRoutine.goToLocator(innerCellLocator2, npc)));

            readyRelease = true;
        }
        else
        {
            yield return(new WaitForSeconds(1.0f));//wait for another gaurd to deal with key

            yield return(StartCoroutine(myRoutine.goToLocator(innerCellLocator2, npc)));

            readyRelease = true;
        }
        while (!gaurd1.GetComponent <NPCgaurd1script>().readyRelease)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        while (!gaurd3.GetComponent <NPCgaurd3script>().readyRelease)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        breakoutTarget.GetComponent <NPCroutine>().uncuff();

        npc._agent.speed = 5;

        yield return(StartCoroutine(myRoutine.goToLocator(l1, npc)));

        haveTarget   = false;
        readyRelease = false;
        stdWalk      = true;
    }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     move      = gameObject.GetComponent <CharacterController>();
     start_loc = new Vector2(transform.position.x, transform.position.z);
     gameObject.transform.position = firstGuy.transform.position;
     gameObject.transform.parent   = firstGuy.transform;
     move = GetComponentInParent <CharacterController>();
     npc  = GetComponentInParent <NPCroutine>();
     npc.writeBox();
     npc.setAllowControl(true);
     npc.changeToGhostMat();
     npc.resistance_build_up = build_up_resistance;
     npc.Vspeed = speed;
     ejected    = false;
     gameObject.GetComponent <SphereCollider>().radius = ghost_radius;
     theGreenSphere.transform.localScale = new Vector3(ghost_radius * 2, ghost_radius * 2, ghost_radius * 2);
 }
예제 #7
0
    public IEnumerator goToLocator(GameObject l, NPCroutine npc)
    {
        if (!skipUpdate)
        {
            _agent.destination = l.transform.position;
        }

        setTargetLoc(l.transform.position);

        Vector2 curr = new Vector2(transform.position.x, transform.position.z);
        Vector2 tar  = new Vector2(l.transform.position.x, l.transform.position.z);

        while (Vector2.SqrMagnitude(tar - curr) > 3)
        {
            yield return(new WaitForSeconds(0.1f));

            curr = new Vector2(transform.position.x, transform.position.z);
        }
    }
예제 #8
0
 // Use this for initialization
 void Start()
 {
     npc    = GetComponent <NPCroutine>();
     _agent = gameObject.GetComponent <NavMeshAgent>();
     StartCoroutine(standardRoutine());
 }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     npc       = GetComponent <NPCroutine>();
     _agent    = gameObject.GetComponent <NavMeshAgent>();
     start_loc = transform.position;
 }
    public IEnumerator getKeyRoutine()
    {
        stdWalk          = false;
        npc.Vspeed       = 5;
        npc._agent.speed = 10;
        NPCroutine myRoutine = gameObject.GetComponent <NPCroutine>();

        bottomDoor.disableInteract = true;

        yield return(StartCoroutine(myRoutine.goToLocator(l2, npc)));

        while (!mat1.GetComponent <keyMatScript>().holdsKey())
        {
            yield return(new WaitForSeconds(0.2f));
        }


        npc.matInteract(mat1);

        yield return(StartCoroutine(myRoutine.goToLocator(l6, npc)));

        bottomDoor.disableInteract = false;
        bottomDoor.interact(npc);
        bottomDoor.disableInteract = true;
        yield return(StartCoroutine(myRoutine.goToLocator(l4, npc)));

        bottomDoor.disableInteract = false;
        bottomDoor.interact(npc);
        bottomDoor.disableInteract = true;
        yield return(StartCoroutine(myRoutine.goToLocator(crazyPrisoner, npc)));

        hitCrazy = false;


        StartCoroutine(crazyPrisoner.GetComponent <NPCroutine>().handcuffTo(npc.gameObject));
        print("PARENTED!");
        crazyPrisoner.GetComponent <crazyScript>().spreadFear();
        npc._agent.speed = 10;
        yield return(new WaitForSeconds(1.0f));

        print("RETURNING...");
        yield return(StartCoroutine(myRoutine.goToLocator(l4, npc)));

        bottomDoor.disableInteract = false;
        bottomDoor.interact(npc);
        bottomDoor.disableInteract = true;
        yield return(StartCoroutine(myRoutine.goToLocator(l6, npc)));

        bottomDoor.disableInteract = false;
        bottomDoor.interact(npc);
        bottomDoor.disableInteract = true;

        cellDoor.disableInteract = true;
        yield return(StartCoroutine(myRoutine.goToLocator(l7, npc)));

        cellDoor.disableInteract = false;
        cellDoor.interact(npc);
        cellDoor.disableInteract = true;

        yield return(StartCoroutine(myRoutine.goToLocator(l3, npc)));

        crazyPrisoner.GetComponent <NPCroutine>().start_loc = (crazyPrisoner.transform.position);
        crazyPrisoner.GetComponent <NPCroutine>().setTargetLoc(crazyPrisoner.transform.position);

        crazyPrisoner.GetComponent <NPCroutine>().uncuff();

        yield return(StartCoroutine(myRoutine.goToLocator(l7, npc)));

        cellDoor.disableInteract = false;
        cellDoor.interact(npc);
        cellDoor.disableInteract = true;

        bottomDoor.disableInteract = false;

        yield return(StartCoroutine(myRoutine.goToLocator(l2, npc)));

        yield return(new WaitForSeconds(1.0f));

        npc.matInteract(mat1);
        gaurd2.GetComponent <NPCgaurd2script>().stage1End = true;
        crazyPrisoner.GetComponent <crazyScript>().stage1 = false;
        npc.Vspeed       = 5;
        npc._agent.speed = 5;
        stdWalk          = true;


        StartCoroutine(fixedRoutine());
        yield return(null);
    }
    public IEnumerator breakout()
    {
        print("starting breakout!");
        while (crazyPrisoner.GetComponent <crazyScript>().stage1 == true)
        {
            yield return(new WaitForSeconds(0.5f));
        }

        if (!npc.ownKey)
        {
            yield return(StartCoroutine(npc.goToLocator(l2.gameObject, npc)));

            npc.matInteract(mat1);
        }

        haveTarget       = false;
        stdWalk          = false;
        npc._agent.speed = 10;
        NPCroutine myRoutine = gameObject.GetComponent <NPCroutine>();

        yield return(StartCoroutine(myRoutine.goToLocator(breakoutTarget, npc)));

        StartCoroutine(breakoutTarget.GetComponent <NPCroutine>().handcuffTo(npc.gameObject));
        yield return(StartCoroutine(myRoutine.goToLocator(breakoutTarget, npc)));

        haveTarget = true;
        while (!gaurd2.GetComponent <NPCgaurd2script>().haveTarget)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        while (!gaurd3.GetComponent <NPCgaurd3script>().haveTarget)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        print("we got em!");

        //if (myRoutine.ownKey)
        //{
        //    //i have the key
        //    yield return StartCoroutine(myRoutine.goToLocator(innerCellLocator1, npc));
        //    if (topDoor.locked)
        //    {
        //        topDoor.interact(npc);
        //    }
        //    yield return StartCoroutine(myRoutine.goToLocator(innerCellLocator2, npc));
        //    readyRelease = true;
        //}
        //else
        //{
        yield return(new WaitForSeconds(1.0f));   //wait for another gaurd to deal with key

        yield return(StartCoroutine(myRoutine.goToLocator(innerCellLocator2, npc)));

        readyRelease = true;
        //}
        while (!gaurd2.GetComponent <NPCgaurd2script>().readyRelease)
        {
            yield return(new WaitForSeconds(0.2f));
        }
        while (!gaurd3.GetComponent <NPCgaurd3script>().readyRelease)
        {
            yield return(new WaitForSeconds(0.2f));
        }

        print("we placed em!");

        breakoutTarget.GetComponent <NPCroutine>().uncuff();

        npc._agent.speed = 5;
        stdWalk          = true;
        yield return(StartCoroutine(gameObject.GetComponent <NPCroutine>().goToLocator(l1, npc)));

        topDoor.disableInteract = false;
        topDoor.interact(npc);
        haveTarget   = false;
        readyRelease = false;
        StartCoroutine(fixedRoutine());
    }
예제 #12
0
 // Use this for initialization
 void Start()
 {
     npc = GetComponent <NPCroutine>();
     StartCoroutine(fixedRoutine());
 }
예제 #13
0
    void Update()
    {
        if (!ejected)
        {
            if (GetComponentInParent <NPCroutine>().ownKey)
            {
                goldKey.enabled = true;
            }
            else
            {
                goldKey.enabled = false;
            }
        }

        if (ejected)
        {
            theBOX.text = " ";
        }

        if (Input.GetKeyUp("space"))
        {
            spaceUp = true;
        }
        if (Input.GetKeyDown("space"))
        {
            spaceUp = false;
            if (!spaceBreak)
            {
                spaceBreak = true;

                Collider[] hitObjects = Physics.OverlapSphere(gameObject.transform.position, ghost_radius);
                // print("Touching objects: ");

                GameObject me = null;

                List <GameObject> closeNPCs = new List <GameObject>();
                foreach (Collider c in hitObjects)
                {
                    //print(c.gameObject);

                    if (c.gameObject.tag.Equals("NPC"))
                    {
                        if (!ejected)
                        {
                            if (c.gameObject.Equals(gameObject.transform.parent.gameObject))
                            {
                                me = c.gameObject;
                                continue;
                            }
                        }
                        closeNPCs.Add(c.gameObject);
                    }
                }
                if (me != null)
                {
                    closeNPCs.Add(me);
                }



                GameObject[] NPCarr = closeNPCs.ToArray();

                if (NPCarr.Length != 0)
                {
                    StartCoroutine(pickInhabit(NPCarr));
                }
                else
                {
                    StartCoroutine(noOneAround());
                }

                /*
                 * if (min_NPC != null){
                 *  if (!ejected)
                 *  {
                 *      npc.setAllowControl(false);
                 *      npc.setControl(false);
                 *  }
                 *
                 *  gameObject.transform.position = min_NPC.transform.position;
                 *  gameObject.transform.parent = min_NPC.transform;
                 *  move = GetComponentInParent<CharacterController>();
                 *  npc = GetComponentInParent<NPCroutine>();
                 *  npc.setAllowControl(true);
                 *
                 *  ejected = false;
                 * }
                 * else
                 * {
                 *  print("nothin to control");
                 * }
                 */
            }
        }


        //Disperse
        if (Input.GetKeyDown(KeyCode.L))
        {
            if (!ejected)
            {
                //not already ejected
                npc.setAllowControl(false);
                lastNpc = npc;
                //npc.setControl(false);
                gameObject.transform.parent = null;
                ejected = true;
            }
            else
            {
                //already ejected
                gameObject.transform.position = lastNpc.transform.position;
                gameObject.transform.parent   = lastNpc.transform;
                move = GetComponentInParent <CharacterController>();
                npc  = GetComponentInParent <NPCroutine>();
                npc.setAllowControl(true);
                npc.writeBox();
                ejected = false;
            }
        }

        if (Input.GetKeyDown(KeyCode.K) && npc != null)
        {
            crazyScript crazy = npc.GetComponent <crazyScript>();
            if (crazy != null)
            {
                Collider[] hitObjects = Physics.OverlapSphere(gameObject.transform.position, ghost_radius);
                // print("Touching objects: ");
                float      min_dist = float.MaxValue;
                GameObject min_NPC  = null;

                foreach (Collider c in hitObjects)
                {
                    //print(c.gameObject);
                    if (c.gameObject.tag.Equals("NPC"))
                    {
                        if (!ejected)
                        {
                            if (c.gameObject.Equals(gameObject.transform.parent.gameObject))
                            {
                                continue;
                            }
                        }

                        float t = Vector3.Magnitude(c.gameObject.transform.position - gameObject.transform.position);
                        if (t < min_dist)
                        {
                            min_dist = t;
                            min_NPC  = c.gameObject;
                        }
                    }
                }
                if (min_dist > 5)
                {
                    print("nothin to fight");
                    return;
                }
                print("fighting: " + min_NPC);
                crazy.goCrazy(min_NPC);
            }
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            if (ejected)
            {
                return;
            }
            if (GetComponentInParent <NPCroutine>().cuffed)
            {
                return;
            }
            Collider[] hitObjects = Physics.OverlapSphere(gameObject.transform.position, ghost_radius);
            // print("Touching objects: ");
            float      min_dist = float.MaxValue;
            GameObject min_mat  = null;

            foreach (Collider c in hitObjects)
            {
                //print(c.gameObject);

                if (c.gameObject.tag.Equals("mat"))
                {
                    if (c.gameObject.Equals(gameObject.transform.parent.gameObject))
                    {
                        continue;
                    }

                    float t = Vector3.Magnitude(c.gameObject.transform.position - gameObject.transform.position);
                    if (t < min_dist)
                    {
                        min_dist = t;
                        min_mat  = c.gameObject;
                    }
                }
                else if (c.gameObject.tag.Equals("gate"))
                {
                    if (c.gameObject.GetComponentInParent <doorScriptGaurd3>() != null)
                    {
                        c.gameObject.GetComponentInParent <doorScriptGaurd3>().interact(GetComponentInParent <NPCroutine>());
                    }
                    else
                    {
                        c.gameObject.GetComponentInParent <doorScript>().interact(GetComponentInParent <NPCroutine>());
                    }

                    //print("gate interacted");
                }
            }

            if (min_mat == null)
            {
                // print("no mats close enough");
            }
            else
            {
                npc.GetComponent <NPCroutine>().matInteract(min_mat);
            }
        }
    }
예제 #14
0
    public IEnumerator pickInhabit(GameObject[] NPClist)
    {
        int        length      = NPClist.Length;
        int        prev        = 0;
        int        current     = 0;
        GameObject selectedNPC = NPClist[0];

        Time.timeScale = 0.075f;

        if (length != 0)
        {
            if (!ejected)
            {
                npc.changeTostandardMat();
            }

            NPClist[current].GetComponent <NPCroutine>().changeToGhostMat();
        }
        float timer = Time.time;

        while (!spaceUp && ((Time.time - timer) < 0.3f))
        {
            yield return(new WaitForSeconds(0.0002f));

            if (length <= 1)
            {
                continue;
            }
            if (Input.GetKeyDown(KeyCode.N))
            {
                current++;
                current = current % length;

                NPClist[current].GetComponent <NPCroutine>().changeToGhostMat();
                NPClist[prev].GetComponent <NPCroutine>().changeTostandardMat();
            }
            prev = current;
        }

        print("exiting space break");

        if (!ejected)
        {
            npc.setAllowControl(false);
        }
        gameObject.transform.position = NPClist[current].transform.position;
        gameObject.transform.parent   = NPClist[current].transform;
        move = GetComponentInParent <CharacterController>();
        npc  = GetComponentInParent <NPCroutine>();
        npc.writeBox();
        npc.resistance_build_up = build_up_resistance;
        npc.Vspeed = speed;
        if (!npc.fighting && !npc.cuffed)
        {
            npc.setAllowControl(true);
        }

        if (ejected && (lastNpc != null) && (lastNpc != npc))
        {
            lastNpc.changeTostandardMat();
            lastNpc = null;
        }

        ejected = false;

        Time.timeScale = 1.0f;
        spaceBreak     = false;
        yield return(null);
    }
 // Use this for initialization
 void Start()
 {
     npc = gameObject.GetComponent <NPCroutine>();
 }