Beispiel #1
0
 void Awake()
 {
     startRotation           = this.transform.rotation.eulerAngles.z;
     rotAdd                  = new Vector3(0, 0, startRotation + 35);
     this.transform.rotation = Quaternion.Euler(0, 0, 0);
     detect                  = this.GetComponent <CanWeDetectTarget> ();
     detect.coneOfVision     = 2.5f;
     rid = this.GetComponent <Rigidbody2D> ();
     fov = this.GetComponentInChildren <FeildOfView> ();
 }
Beispiel #2
0
 void Awake()
 {
     pmc      = this.GetComponent <PersonMovementController> ();
     pwc      = this.GetComponent <PersonWeaponController> ();
     inv      = this.GetComponent <Inventory> ();
     detect   = this.GetComponent <CanWeDetectTarget> ();
     pf       = this.GetComponent <PathFollower> ();
     memory   = this.GetComponent <NPCMemory> ();
     npcB     = this.GetComponent <NPCBehaviourDecider> ();
     myCol    = this.GetComponent <PersonColliderDecider> ();
     myHealth = this.gameObject.GetComponent <PersonHealth> ();
     ac       = this.GetComponentInChildren <ArtemAnimationController> ();
     pcc      = this.GetComponent <PersonClothesController> ();
 }
Beispiel #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);
                //}
            }
        }
    }