Exemple #1
0
    public bool OnPickObject(PickableObject.PickableType type)
    {
        if (type == PickableObject.PickableType.pistol &&
            currentWeapon != 1)
        {
            if (currentWeapon == 0)
            {
                ChangeWeapon(1);
                return(true);
            }
            else
            {
                ChangeWeapon(0);
                return(true);
            }
        }
        else if (type == PickableObject.PickableType.shotgun &&
                 currentWeapon != 2)
        {
            ChangeWeapon(2);
            return(true);
        }
        else if (type == PickableObject.PickableType.rifle &&
                 currentWeapon != 3)
        {
            ChangeWeapon(3);
            return(true);
        }
        else if (type == PickableObject.PickableType.booze)
        {
            if (hp < MAXHP)
            {
                hp = Mathf.Min(MAXHP, hp + 2);

                return(true);
            }
        }
        else if (type == PickableObject.PickableType.horse)
        {
            GameManager.End();
        }
        return(false);
    }
Exemple #2
0
    public static PickableObject DropAt(PickableObject.PickableType type, Vector3 pos)
    {
        PickableObject template = null;

        if (type == PickableObject.PickableType.booze)
        {
            template = instance.pickBooze;
        }
        else if (type == PickableObject.PickableType.pistol)
        {
            template = instance.pickPistol;
        }
        else if (type == PickableObject.PickableType.shotgun)
        {
            template = instance.pickShotgun;
        }
        else if (type == PickableObject.PickableType.rifle)
        {
            template = instance.pickRifle;
        }

        if (template != null)
        {
            PickableObject result = GameObject.Instantiate <PickableObject>(template);
            result.gameObject.SetActive(true);
            result.transform.position   = pos;
            result.transform.parent     = template.transform.parent;
            result.transform.localScale = template.transform.localScale;

            return(result);
        }
        else
        {
            return(null);
        }
    }