void InventoryControl() { if (inventory != null) { for (int i = 1; i < inventory.maxNumberOfSlots + 1; i++) { if (Input.GetKeyDown("" + i)) { Item item = inventory.ReturnItem(i - 1); if (item != null) { if (item.GetType().IsSubclassOf(typeof(Equipment))) { //If item is an equipment... itemAction.EquipItem((Equipment)item, orientation); } else { //If item is a normal item... itemAction.HoldItem(item, orientation); } } } } } }
void Start() { GameObject weaponObject = Instantiate(weaponPrefab); weaponObject.transform.localScale = Vector3.one * 2; SpiderCannon weapon = weaponObject.GetComponent <SpiderCannon>(); centerTransform = transform.GetChild(0); equipAction = GetComponent <EquipAction>(); equipAction.EquipItem(weapon, centerTransform); }
void Start() { centerTransform = transform.GetChild(0); centerTransform.rotation = transform.rotation; this.direction = this.transform.eulerAngles; this.position = this.transform.position; this.currentSpeed = 0.0f; targetDetected = targetCanBeSeen = targetInLineOfSight = targetInShootingRange = false; movementAI = GetComponent <MovementAI>(); GameObject weaponObject = Instantiate(weaponPrefab); RangeWeapon weapon = weaponObject.GetComponent <RangeWeapon>(); equipAction = GetComponent <EquipAction>(); equipAction.EquipItem(weapon, this.centerTransform); }
void Start() { playerView.enabled = true; playerView.transform.position = transform.position + Vector3.up * .5f; playerView.transform.eulerAngles = this.direction = transform.eulerAngles; playerView.fieldOfView = 95f; itemAction = GetComponent <EquipAction>(); this.currentSpeed = this.maxSpeed; if (weaponPrefab != null) { GameObject weaponObject = (GameObject)Instantiate(weaponPrefab); RangeWeapon weapon = weaponObject.GetComponent <RangeWeapon>(); itemAction.EquipItem(weapon, playerView.transform); } Cursor.lockState = CursorLockMode.Locked; position = transform.position; }