예제 #1
0
    //need to add way of reversing hostage taking,add behaviour to cops, guards to free hostages
    public override void doAction()
    {
        illigal = true;

        myDoor.locked = false;
        //myDoor.interactWithDoor (CommonObjectsStore.player);
        myDoor.kickInDoor();
        CommonObjectsStore.player.GetComponent <PersonWeaponController> ().Punch();
        foreach (GameObject g in NPCManager.me.npcsInWorld)
        {
            if (g == null)
            {
                continue;
            }
            NPCController npc = g.GetComponent <NPCController> ();
            npc.setHearedGunshot(this.transform.position, 7.0f);
        }
        PoliceController.me.setNoiseHeard(this.transform.position, 7.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);
            }
        }
    }
예제 #3
0
    void newMeleeDealDamage(GameObject g)
    {
        if (g.tag == this.gameObject.tag)
        {
            //Debug.Log ("hit freindly, returning");
            return;
        }


        if (currentWeapon == null)
        {
            //foreach (GameObject g in objectsRayHitInSwing) {
            PersonHealth ph = g.GetComponent <PersonHealth> ();
            if (ph == null)
            {
                if (g.tag == "Door")
                {
                    //Debug.Log ("Melee hit " + g.gameObject.name);
                    DoorScript ds = g.GetComponent <DoorScript> ();
                    if (ds == null)
                    {
                        if (g.transform.parent == null)
                        {
                            //Debug.Log ("Could not find door script in parent");
                        }
                        else
                        {
                            ds = g.transform.root.gameObject.GetComponent <DoorScript> ();
                        }
                    }


                    if (ds == null)
                    {
                        //Debug.Log ("Could not find door script");
                    }
                    else
                    {
                        ds.kickInDoor();
                    }
                    ////////Debug.Log ("Door " + ds.gameObject + " kicked in");
                    return;
                }
                else if (g.tag == "Window")
                {
                    Window w = g.GetComponent <Window> ();
                    //Debug.Log (g.name);
                    if (w == null)
                    {
                    }
                    else
                    {
                        w.smashWindow();
                    }

                    WindowNew w2 = g.GetComponentInParent <WindowNew> ();
                    if (w2 == null)
                    {
                    }
                    else
                    {
                        w2.destroyWindow();
                    }

                    return;
                }
                else if (g == this.gameObject)
                {
                    return;
                }
                else
                {
                }
            }
            else
            {
                if (g == this.gameObject || ph.healthValue <= 0)
                {
                    return;
                }

                if (g.tag != "Player")
                {
                    Inventory i = ph.gameObject.GetComponent <Inventory> ();
                    if (i.leftArm == null)
                    {
                    }
                    else
                    {
                        Item toDrop = i.leftArm;
                        i.unequipItem(toDrop);

                        i.dropItem(toDrop);
                    }

                    if (i.rightArm == null)
                    {
                    }
                    else
                    {
                        Item toDrop = i.rightArm;
                        i.unequipItem(toDrop);

                        i.dropItem(toDrop);
                    }
                }
                NPCController npc = g.GetComponent <NPCController> ();
                if (npc == null)
                {
                    ph.gameObject.GetComponent <BleedingEffect> ().bloodImpact(g.transform.position, Quaternion.Euler(0, 0, this.transform.eulerAngles.z - 90));

                    //bool inFront = detect.isTargetInFrontOfUs (this.gameObject);
                    ph.dealMeleeDamage(500, false);
                    punchNoise();
                }
                else
                {
                    ph.gameObject.GetComponent <BleedingEffect> ().bloodImpact(g.transform.position, Quaternion.Euler(0, 0, this.transform.eulerAngles.z - 90));

                    CanWeDetectTarget detect = g.GetComponent <CanWeDetectTarget> ();
                    //bool inFront = detect.isTargetInFrontOfUs (this.gameObject);
                    ph.dealMeleeDamage(500, false);
                    punchNoise();
                    if (ph.healthValue > 0)
                    {
                        if (isTargetFacingAway(npc.gameObject))
                        {
                            npc.knockOutNPC();
                        }
                        ph.setAttacked(this.gameObject);
                        npc.stunTimer = 3.0f;
                        ////////Debug.Break ();
                    }

                    //if (inFront == true) {
                    if (this.gameObject.tag == "Player")                      //TODO may need to rewrite this in the far future
                    {
                        npc.memory.peopleThatHaveAttackedMe.Add(this.gameObject);
                    }

                    //}
                    if (g.tag == "NPC")
                    {
                        npc.memory.objectThatMadeMeSuspisious = this.gameObject;
                        npc.npcB.onHostageRelease();
                    }
                }
            }
        }
        else
        {
            PersonHealth ph = g.GetComponent <PersonHealth> ();
            if (ph == null)
            {
                if (g.tag == "Door")
                {
                    //Debug.Log ("Melee hit " + g.gameObject.name);
                    DoorScript ds = g.GetComponent <DoorScript> ();
                    if (ds == null)
                    {
                        if (g.transform.parent == null)
                        {
                            //Debug.Log ("Could not find door script in parent");
                        }
                        else
                        {
                            ds = g.transform.root.gameObject.GetComponent <DoorScript> ();
                        }
                    }


                    if (ds == null)
                    {
                        //Debug.Log ("Could not find door script");
                    }
                    else
                    {
                        ds.kickInDoor();
                    }
                    ////////Debug.Log ("Door " + ds.gameObject + " kicked in");
                    return;
                }
                else if (g.tag == "Window")
                {
                    Window w = g.GetComponent <Window> ();
                    //Debug.Log (g.name);
                    if (w == null)
                    {
                    }
                    else
                    {
                        w.smashWindow();
                    }

                    WindowNew w2 = g.GetComponentInParent <WindowNew>();
                    if (w2 == null)
                    {
                    }
                    else
                    {
                        w2.destroyWindow();
                    }

                    return;
                }
                else if (g.GetComponent <PlayerCarController> () == true)
                {
                    g.GetComponent <PlayerCarController> ().dealDamage(500);
                    return;
                }
                else if (g == this.gameObject)
                {
                    return;
                }
            }
            else
            {
                if (g == this.gameObject || ph.healthValue <= 0)
                {
                    return;
                }

                NPCController npc = g.GetComponent <NPCController> ();
                if (npc == null)
                {
                    ph.gameObject.GetComponent <BleedingEffect> ().bloodImpact(g.transform.position, Quaternion.Euler(0, 0, this.transform.eulerAngles.z - 90));

                    //bool inFront = detect.isTargetInFrontOfUs (this.gameObject);
                    ph.dealMeleeDamage(currentWeapon.meleeDamage, currentWeapon.bladed);
                    punchNoise();
                }
                else
                {
                    ph.gameObject.GetComponent <BleedingEffect> ().bloodImpact(g.transform.position, Quaternion.Euler(0, 0, this.transform.eulerAngles.z - 90));

                    CanWeDetectTarget detect = g.GetComponent <CanWeDetectTarget> ();
                    //bool inFront = detect.isTargetInFrontOfUs (this.gameObject);
                    ph.dealMeleeDamage(currentWeapon.meleeDamage, currentWeapon.bladed);
                    punchNoise();
                    if (ph.healthValue > 0)
                    {
                        if (currentWeapon.bladed == false && isTargetFacingAway(npc.gameObject))
                        {
                            npc.knockOutNPC();
                        }
                        ph.setAttacked(this.gameObject);

                        ////////Debug.Break ();
                    }

                    //if (inFront == true) {
                    if (this.gameObject.tag == "Player")                      //TODO may need to rewrite this in the far future
                    {
                        npc.memory.peopleThatHaveAttackedMe.Add(this.gameObject);
                    }

                    //}
                    if (g.tag == "NPC")
                    {
                        npc.memory.objectThatMadeMeSuspisious = this.gameObject;
                        npc.npcB.onHostageRelease();
                    }
                }
                //if (g != this.gameObject) {
                //	ph.dealMeleeDamage (100, false);
                //}
            }
        }
    }
예제 #4
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject == null)
        {
        }
        else
        {
            if (col.gameObject.tag == "Door")
            {
                DoorScript ds = col.gameObject.GetComponent <DoorScript> ();
                if (ds == null)
                {
                }
                else
                {
                    ds.kickInDoor();
                    Instantiate(CommonObjectsStore.me.bulletImpact, this.transform.position - (transform.up / 4), this.transform.rotation);
                    Destroy(this.gameObject);
                }
                //if (ds.wayIAmLocked == lockedWith.none || ds.wayIAmLocked == lockedWith.key) {
                //	ds.locked = false;
                //	ds.interactWithDoor (this.gameObject);
                //}
            }
            else if (col.gameObject.tag == "Window")
            {
                Window w = col.gameObject.GetComponent <Window> ();
                if (w == null)
                {
                }
                else
                {
                    w.smashWindow();
                    return;
                }

                WindowNew w2 = col.gameObject.GetComponentInParent <WindowNew> ();
                if (w2 == null)
                {
                }
                else
                {
                    w2.destroyWindow();
                }
            }
            else if (col.gameObject.GetComponent <PlayerCarController> () == true)
            {
                col.gameObject.GetComponent <PlayerCarController> ().dealDamage(damage);

                if (col.gameObject.GetComponent <SpawnCopsOnCall> () == true)
                {
                    col.gameObject.GetComponent <SpawnCopsOnCall> ().spawnCops();
                    if (PoliceController.me.copsCalled == false)
                    {
                        PoliceController.me.copsCalled = true;
                    }
                }
            }

            if (col.gameObject.tag != "Bullet")
            {
                if (col.gameObject.tag == "NPC" && isAiBullet == false || col.gameObject.tag == "Player" && isAiBullet == true)
                {
                    Instantiate(CommonObjectsStore.me.bloodImpact, this.transform.position - (transform.up / 4), this.transform.rotation);
                }

                if (col.transform.root.tag != "Player" && col.transform.root.tag != "NPC")
                {
                    Instantiate(CommonObjectsStore.me.bulletImpact, this.transform.position - (transform.up / 4), this.transform.rotation);
                }

                Destroy(this.gameObject);
            }
        }
    }