Пример #1
0
        public void CalcNextStep()
        {
            if (CalcIsAtHome())
            {
                timeAtHome += 1;
            }
            else
            {
                timeAtHome = 0;
            }
            IsBored = timeAtHome >= 5;

            switch (Health)
            {
            case PersonHealth.Dead:
                StepsToRot--;
                return;

            case PersonHealth.Sick:
            {
                StepsToRecovery--;
                if (StepsToRecovery == 0)
                {
                    Health = PersonHealth.Healthy;
                }
                else if (TryToDie())
                {
                    return;
                }
                break;
            }
            }
            Move();
        }
Пример #2
0
        public void CalcNextStep()
        {
            if (PersonHealth == PersonHealth.Dead)
            {
                return;
            }

            if (PersonHealth == PersonHealth.Dying)
            {
                deadStepsCount++;
                if (deadStepsCount >= StepsToDie)
                {
                    PersonHealth = PersonHealth.Dead;
                }
                return;
            }

            switch (state)
            {
            case PersonState.AtHome:
                CalcNextStepForPersonAtHome();
                break;

            case PersonState.Walking:
                CalcNextPositionForWalkingPerson();
                break;

            case PersonState.GoingHome:
                CalcNextPositionForGoingHomePerson();
                break;
            }

            if (PersonHealth == PersonHealth.Sick)
            {
                if (random.NextDouble() <= ProbToDie)
                {
                    PersonHealth = PersonHealth.Dying;
                }
                sickStepsCount++;
                if (sickStepsCount >= StepsToRecovery)
                {
                    PersonHealth = PersonHealth.Healthy;
                }
            }
            if (state == PersonState.AtHome)
            {
                HomeStayingDuration++;
            }
            else if (state == PersonState.Walking)
            {
                HomeStayingDuration = 0;
                IsBored             = false;
            }

            if (HomeStayingDuration > 4)
            {
                IsBored = true;
            }
        }
Пример #3
0
 void Start()
 {
     if (CommonObjectsStore.player == this.gameObject)
     {
         playerHealth = this;
     }
     be = this.GetComponent <BleedingEffect> ();
 }
Пример #4
0
 void Awake()
 {
     pmc         = this.gameObject.GetComponentInParent <PersonMovementController> ();
     pwc         = this.gameObject.GetComponentInParent <PersonWeaponController> ();
     myHealth    = this.gameObject.GetComponentInParent <PersonHealth> ();
     myAesthetic = this.GetComponent <PersonAestheticStore> ();
     setBodySprites();
     myRenderers = this.transform.root.gameObject.GetComponentsInChildren <SpriteRenderer> ();
 }
Пример #5
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject == null)
        {
        }
        else
        {
            stopMovement();
            ////////Debug.Log ("WEAPON HIT SOMETHING" + col.gameObject.name);
            if (col.gameObject.tag == "Player")
            {
                CameraController.me.hitByBullet(new Vector2(this.transform.position.x, this.transform.position.y));
            }

            PersonHealth ph = col.gameObject.GetComponent <PersonHealth> ();
            if (ph == null)
            {
            }
            else
            {
                ph.dealDamage(damage, false);
                //stun npc

                if (ph.healthValue > 0 && this.gameObject.tag == "NPC")
                {
                    NPCController npc = col.collider.gameObject.GetComponent <NPCController> ();
                    npc.knockOutNPC();
                }

                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);
                }
            }

            //Destroy (this.gameObject);
        }
    }
Пример #6
0
    void OnTrigger2DEnter(Collider2D other)
    {
        PersonHealth ph = other.gameObject.transform.parent.GetComponent <PersonHealth> ();

        if (ph == null)
        {
        }
        else
        {
            ph.dealDamage(2500, true);
        }
    }
Пример #7
0
        public void ChangeHealth(PersonHealth next)
        {
            Health = next;
            switch (next)
            {
            case PersonHealth.Sick:
                StepsToRecovery = InitialStepsToRecovery;
                break;

            case PersonHealth.Dead:
                StepsToRot = InitialStepsToRot;
                break;
            }
        }
Пример #8
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> ();
 }
Пример #9
0
    private void Start()
    {
        if (myId != -1)
        {
            NPCIDManager.me.addID(this);
        }
        if (shouldIActivate())
        {
            if (shouldIDeactivate())
            {
                this.gameObject.SetActive(false);
            }
            else
            {
                if (dead == true)
                {
                    int timeSinceMurder = TimeScript.me.howManyHoursHavePassed(hourOfMurder, dayOfMurder, monthOfMurder, yearOfMurder);
                    if (timeSinceMurder > 24)
                    {
                        this.gameObject.SetActive(false);
                        // NPCIDManager.me.idsInWorld.Remove(this);
                        // Destroy(this.gameObject);
                    }
                    else
                    {
                        this.GetComponent <PersonHealth>().dealDamage(10000, false);
                    }
                }
                else if (madeHostileToPlayer == true)
                {
                    this.GetComponent <NPCBehaviourDecider>().myType = AIType.uniqueHostile;
                    NPCMemory m = this.GetComponent <NPCMemory>();
                    m.peopleThatHaveAttackedMe = new List <GameObject>();
                    m.peopleThatHaveAttackedMe.Add(CommonObjectsStore.player);
                    m.beenAttacked = true;
                    m.objectThatMadeMeSuspisious = CommonObjectsStore.player;
                }
                else
                {
                    this.GetComponent <NPCBehaviourDecider>().myType = AIType.uniqueNeutral;
                }
            }
        }
        else
        {
            this.gameObject.SetActive(false);
        }

        ph = this.GetComponent <PersonHealth>();
    }
    public override bool canDo()
    {
        if (ph == null)
        {
            ph = this.gameObject.GetComponent <PersonHealth> ();
        }


        if (ph.healthValue <= 0)
        {
            return(false);
        }

        if (PlayerAction.currentAction == null)
        {
            return(false);
        }
        else
        {
            if (PlayerAction.currentAction == null)
            {
                return(false);
            }

            if (this.transform.parent == null)
            {
                return(false);
            }

            if (this.gameObject.tag == "Dead/Knocked")
            {
                return(false);
            }

            if (PlayerAction.currentAction.getType() == "Take Hostage" && this.transform.root.gameObject.tag == "Player")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
Пример #11
0
    void OnTriggerStay2D(Collider2D other)
    {
        //Debug.Log ("Fire triggered by " + other.gameObject.name);
        PersonHealth ph = other.gameObject.transform.root.GetComponent <PersonHealth> ();

        if (ph == null)
        {
        }
        else
        {
            ph.dealDamageFromFire();
        }

        PlayerCarController pcc = other.GetComponent <PlayerCarController> ();

        if (pcc == null)
        {
        }
        else
        {
            pcc.dealDamage(10);
        }
    }
Пример #12
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);
                //}
            }
        }
    }
Пример #13
0
 void Start()
 {
     ph = this.GetComponentInParent <PersonHealth> ();
 }
Пример #14
0
 void Awake()
 {
     ph = this.gameObject.GetComponent <PersonHealth> ();
     p  = this.GetComponentInChildren <ParticleSystem> ().gameObject;
     p.SetActive(bleeding);
 }