Exemple #1
0
    public void PickUpItem(GameObject item)
    {
        FMOD_StudioSystem.instance.PlayOneShot("event:/player/weaponEquip02", transform.position, PlayerPrefs.GetFloat("MasterVolume") / 6f);
        GameObject temp = (GameObject)Instantiate(item, Vector3.zero, Quaternion.identity);

        temp.transform.parent        = playerInventoryRef.transform;
        temp.transform.localPosition = Vector3.zero;
        if (inventory.Count < 10 && (temp.GetComponent <Weapon>() != null || temp.GetComponent <Hack>() != null))
        {
            inventory.Add(temp.GetComponent <Item>());
        }
        else if (inventory.Capacity < 11)
        {
            inventory.Capacity = 11;
            inventory[10]      = temp.GetComponent <Item>();
        }
        else
        {
            inventory.Add(temp.GetComponent <Item>());
        }

        if (temp.GetComponent <Hack>() == null)
        {
            temp.SetActive(false);
        }
        else
        {
            temp.SetActive(true);
        }

        PlayerCanvas.UpdateInventory();

        if (item.GetComponent <Armor>() != null)
        {
            EquipArmor(temp);
        }

        if (activeWeapon == null && item.GetComponent <Weapon>() != null)
        {
            SetActiveItem(0);
        }

        if (activeHack == null && item.GetComponent <Hack>() != null)
        {
            SetActiveItem(1);
        }

        ActionEventInvoker.primaryInvoker.invokeAction(new PlayerAction(temp.GetComponent <Item> ().getDirectObject(), ActionType.PICKED_UP_OBJECT));
    }
Exemple #2
0
    void Start()
    {
        weaponRef = GameObject.Find("PlayerWeaponObj");
        if (PersistentInfo.playerName != null && !PersistentInfo.playerName.Equals(""))
        {
            if (PersistentInfo.playerName.Contains("\n"))
            {
                PersistentInfo.playerName = PersistentInfo.playerName.Substring(0, PersistentInfo.playerName.Length - 1);
            }
            this.name = PersistentInfo.playerName;
        }
        else if (PersistentInfo.saveFile > 0 && !MasterDriver.bossLevel)
        {
            MasterDriver.Instance.loadGame = true;
        }

        levelUpParticles = GameObject.Find("LevelUpParticles").GetComponent <ParticleSystem>();

        //Need to figure out a better way to load the hitinfo prefab
        hitInfo = Resources.Load <GameObject>("Info/HitInfo");

        //setting initial integrity and rma values
        integrity = maxIntegrity;
        rma       = maxrma;

        //initializing the references to the player inventory, armor points, and weaponhand
        playerInventoryRef = GameObject.Find("PlayerInventory");
        playerPos          = transform;
        bytesToNextVersion = ((int.Parse(version.Split('.')[0])) * 10 + (int.Parse(version.Split('.')[1])) * 50) * levelUpSpeedScale;

        //setting up inventory
        inventory = new List <Item>();
        if (weaponRef.transform.childCount != 0)
        {
            inventory.Add(weaponRef.transform.GetChild(0).GetComponent <Item>());
        }
        for (int i = 0; i < playerInventoryRef.transform.childCount; i++)
        {
            inventory.Add(playerInventoryRef.transform.GetChild(i).GetComponent <Item>());
        }

        //setting up playerarmor
        playerArmor = new GameObject[4];

        leftUpLegRef     = transform.Find("Character1_Reference/Character1_Hips/Character1_LeftUpLeg").GetComponent <Transform>();
        rightUpLegRef    = transform.Find("Character1_Reference/Character1_Hips/Character1_RightUpLeg").GetComponent <Transform>();
        leftLegRef       = transform.Find("Character1_Reference/Character1_Hips/Character1_LeftUpLeg/Character1_LeftLeg").GetComponent <Transform>();
        rightLegRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_RightUpLeg/Character1_RightLeg").GetComponent <Transform>();
        leftFootRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_LeftUpLeg/Character1_LeftLeg/Character1_LeftFoot").GetComponent <Transform>();
        rightFootRef     = transform.Find("Character1_Reference/Character1_Hips/Character1_RightUpLeg/Character1_RightLeg/Character1_RightFoot").GetComponent <Transform>();
        spineRef         = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine").GetComponent <Transform>();
        leftShoulderRef  = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder").GetComponent <Transform>();
        rightShoulderRef = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder").GetComponent <Transform>();
        leftArmRef       = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder/Character1_LeftArm").GetComponent <Transform>();
        leftForearmRef   = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder/Character1_LeftArm/Character1_LeftForeArm").GetComponent <Transform>();
        leftHandRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_LeftShoulder/Character1_LeftArm/Character1_LeftForeArm/Character1_LeftHand").GetComponent <Transform>();
        rightArmRef      = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder/Character1_RightArm").GetComponent <Transform>();
        rightForearmRef  = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder/Character1_RightArm/Character1_RightForeArm").GetComponent <Transform>();
        rightHandRef     = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_RightShoulder/Character1_RightArm/Character1_RightForeArm/Character1_RightHand").GetComponent <Transform>();
        headRef          = transform.Find("Character1_Reference/Character1_Hips/Character1_Spine/Character1_Spine1/Character1_Neck/Character1_Head").GetComponent <Transform>();

        //setting up initial weapon and hack (not the best way to do this since
        //it requires that the first item in the inventory prefab needs to be a hack
        if (inventory.Count > 1)
        {
            activeWeapon = (Weapon)inventory[0];
            activeHack   = (Hack)inventory[1];
            SetActiveItem(0);
            SetActiveItem(1);
        }

        if (!Application.loadedLevel.Equals("KartikTesting"))
        {
            respawnLoc = transform.position;
        }

        //sets up quickaccessitems and makes the canvas update the inventory ui
        PlayerCanvas.UpdateInventory();
//		Debug.LogError(GetName());
    }