//need to add way of reversing hostage taking,add behaviour to cops, guards to free hostages
    public override void doAction()
    {
        illigal = false;

        myDoor.locked = false;
        myDoor.interactWithDoor(CommonObjectsStore.player);
        PlayerAction.currentAction = null;
    }
Beispiel #2
0
 public void enterCode()
 {
     if (getInputNumber() == doorToOpen.keycodeNumber)
     {
         doorToOpen.locked = false;
         doorToOpen.interactWithDoor(CommonObjectsStore.player);
         PlayerAction.currentAction = null;
         disableGUI();
     }
     else
     {
         //have a beep to indicate its wrong
     }
 }
    //need to add way of reversing hostage taking,add behaviour to cops, guards to free hostages
    public override void doAction()
    {
        myDoor.interactWithDoor(CommonObjectsStore.player);

        foreach (GameObject g in NPCManager.me.npcsInWorld)
        {
            if (g == null)
            {
                continue;
            }
            NPCController npc = g.GetComponent <NPCController> ();
            if (npc.npcB.myType != AIType.civilian)
            {
                npc.setHearedGunshot(this.transform.position, 4.0f);
            }
        }
        PoliceController.me.setNoiseHeard(this.transform.position, 4.0f);

        PlayerAction.currentAction = null;
    }
    void Update()
    {
        if (explosivePlaced == true)
        {
            timer -= Time.deltaTime;
            ////////Debug.Log ("Explosive Beep");
            if (timer <= 0)
            {
                Instantiate(CommonObjectsStore.me.explosion, this.transform.position, this.transform.rotation);
                myDoor.locked = false;
                myDoor.interactWithDoor(CommonObjectsStore.player);
                myDoor.doorHealth = 0;
                myDoor.kickInDoor();
                for (int x = 0; x < 4; x++)
                {
                    Vector3 pos = new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), 0.0f);
                    Instantiate(CommonObjectsStore.me.explosion, this.transform.position + pos, this.transform.rotation);
                }
                PlayerAction.currentAction = null;
                this.enabled = false;
                //create explosion
                foreach (GameObject g in NPCManager.me.npcsInWorld)
                {
                    if (g == null)
                    {
                        continue;
                    }
                    NPCController npc = g.GetComponent <NPCController> ();
                    npc.setHearedGunshot(this.transform.position, 50.0f);
                }
                PoliceController.me.setNoiseHeard(this.transform.position, 50.0f);

                //	Destroy (this.gameObject);
            }
        }
    }
Beispiel #5
0
    void openDoor()
    {
        Vector3 heading = this.transform.up.normalized;

        RaycastHit2D[] rays = Physics2D.RaycastAll(this.transform.position, heading, 1.5f);
        ////Debug.DrawRay (this.transform.position, heading* 1.0f,Color.red);

        foreach (RaycastHit2D ray in rays)
        {
            if (ray.collider == null)
            {
            }
            else
            {
                if (ray.collider.gameObject.tag == "Car" || ray.collider.transform.root.tag == "Car")
                {
                    NPCController npc = this.gameObject.GetComponent <NPCController> ();

                    //if (npc.pmc.frozen == false && npc.pmc.movedThisFrame == true) {
                    myController.pmc.setStopped();
                    //}

                    if (myController.pf.waitingForPath == false)
                    {
                        myController.pf.ForceNewPath();
                    }
                }
                else if (ray.collider.gameObject.tag == "Door")
                {
                    DoorScript ds = ray.collider.gameObject.GetComponent <DoorScript> ();                   //TODO work out some method of obstacle avoidance
                    if (ds == null)
                    {
                        ds = ray.collider.gameObject.GetComponentInParent <DoorScript> ();
                        if (ds.doorOpen == false && ds.canNPCOpenDoor(myController.npcB.myID))
                        {
                            ds.interactWithDoor(this.gameObject);
                        }
                    }
                    else
                    {
                        if (ds.doorOpen == false && ds.canNPCOpenDoor(myController.npcB.myID))
                        {
                            ds.interactWithDoor(this.gameObject);
                        }
                    }
                }
                else if (ray.collider.gameObject.tag == "NPC" && ray.collider.gameObject != this.gameObject)
                {
                    NPCController npc = ray.collider.gameObject.GetComponent <NPCController> ();

                    //if (npc.npcB.myType == myController.npcB.myType) {
                    //	if (npc.pmc.frozen == false && npc.pmc.movedThisFrame == true) {
                    //		myController.pmc.setStopped ();
                    //	}
                    //}
                }
                else if (ray.collider.gameObject.tag == "Walls" || ray.collider.gameObject.tag == "ImpassableObject")
                {
                    myController.pf.increaseStuckCounter();
                }
            }
        }
        //Physics2D.queriesStartInColliders = true;
    }