Esempio n. 1
0
    public void fight(Person victim)
    {
        // need to add fight code
        // blood, scalps, health, etc.
        StatusText status = (StatusText)GameObject.Find("StatusText").GetComponent("StatusText");

        throwBlood(victim);

        victim.health -= (int)(damage * (1 + Random.Range(-Config.DAMAGE_VARIANCE, Config.DAMAGE_VARIANCE)));

        if (victim.health <= 0)
        {
            //throwBlood(victim);
            scalps += victim.scalps + 1;
            status.addText(personNameCap + " kills and scalps " + victim.personName + ".");
            victim.dead = true;
            GameObject corpse = (GameObject)Instantiate(Corpse);
            corpse.transform.position = new Vector3(victim.transform.position.x, victim.transform.position.y, victim.transform.position.z);
            Destroy(victim.gameObject);
        }
        else
        {
            throwBlood(this);

            health -= (int)(victim.damage * (1 + Random.Range(-Config.DAMAGE_VARIANCE, Config.DAMAGE_VARIANCE)));

            if (health <= 0)
            {
                //throwBlood(this);

                status.addText(victim.personNameCap + " kills " + personName + ".");
                dead   = true;
                scalps = 0;
                //Destroy (this);
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        Hunter[]   hunters   = FindObjectsOfType(typeof(Hunter)) as Hunter[];
        Location[] locations = FindObjectsOfType(typeof(Location)) as Location[];
        StatusText status    = (StatusText)GameObject.Find("StatusText").GetComponent("StatusText");

        foreach (Location l in locations)
        {
            l.hunterCount = 0;
        }

        int hCount = 0;

        foreach (Hunter h in hunters)
        {
            if (!h.dead)
            {
                hCount++;
            }
        }

        bool found = false;

        foreach (Hunter h in hunters)
        {
            if (h.dead)
            {
                continue;
            }

            foreach (Location l in locations)
            {
                if (!(h.gameObject.renderer.bounds.min.x > l.gameObject.renderer.bounds.max.x ||
                      h.gameObject.renderer.bounds.max.x < l.gameObject.renderer.bounds.min.x ||
                      h.gameObject.renderer.bounds.min.y > l.gameObject.renderer.bounds.max.y ||
                      h.gameObject.renderer.bounds.max.y < l.gameObject.renderer.bounds.min.y))
                {
                    l.hunterCount++;
                    if (l.hunterCount > hCount / 2)
                    {
                        found = true;
                        if (currentLocation != l)
                        {
                            currentLocation = l;
                            status.addText("The gang enters " + l.locationName + ".");
                            notFound = 0;
                            break;
                        }
                    }
                }
            }
        }

        if (!found)
        {
            notFound++;
            if (notFound > Config.EXIT_LOCATION_THRESHOLD)
            {
                currentLocation = null;
                notFound        = 0;
            }
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (dead)
        {
            return;
        }

        // chase mouse pointer
        Vector3    mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Person     victim        = null;
        StatusText status        = (StatusText)GameObject.Find("StatusText").GetComponent("StatusText");

        if ((victim = walkTowards(mousePosition)) != null)
        {
            if ((victim as Hunter) == null && victim.dead != true)
            {
                fight(victim);
            }
            else
            {
                fidget();
            }
        }

        // sell scalps, upgrade, heal
        LocationTracker location = (LocationTracker)GameObject.Find("LocationTracker").GetComponent("LocationTracker");

        if (location.currentLocation != null && location.currentLocation.locationName == "Chihuahua")
        {
            if (horse == false && scalps > Config.HORSE_COST)
            {
                scalps -= Config.HORSE_COST;
                horse   = true;
                status.addText(personNameCap + " buys a horse.", true);
            }

            if (damage == Config.BAREHAND_DAMAGE && scalps >= Config.KNIFE_COST)
            {
                scalps -= Config.KNIFE_COST;
                damage  = Config.KNIFE_DAMAGE;
                status.addText(personNameCap + " buys a large knife.", true);
            }
            else if (damage == Config.KNIFE_DAMAGE && scalps >= Config.PISTOL_COST)
            {
                scalps -= Config.PISTOL_COST;
                damage  = Config.PISTOL_DAMAGE;
                status.addText(personNameCap + " buys a " + (Random.Range(0, 2) == 0?"Colt Paterson pistol":"Whitneyville Colt pistol") + ".", true);
            }
            else if (damage == Config.PISTOL_DAMAGE && scalps >= Config.RIFLE_COST)
            {
                scalps -= Config.RIFLE_COST;
                damage  = Config.RIFLE_DAMAGE;
                status.addText(personNameCap + " buys a Wesson rifle.", true);
            }

            if (health < Config.HUNTER_MAX_HEALTH - 10 && scalps > 0)
            {
                health = Config.HUNTER_MAX_HEALTH;
                status.addText(personNameCap + " eats, drinks and feels better.", true);
                --scalps;
            }
        }
    }