void Start() { camCtrl = GameObject.Find("Main Camera Parent"); stopwatch = new Stopwatch(); rb = this.gameObject.GetComponent <Rigidbody>(); pickupManager = GameObject.Find("PickupHandler").GetComponent <PickupBehaviour>(); }
public void OnDrop() { Ability abilityBeingDropped = abilityInfoDisplay.currentlySelectedAbility; // We store the coordinates we want the object to spawn at - the player's current position. // The second vector prevents 2 pickups spawning exactly on top of each other, which prevent's their colliders pushing them away from one another. Vector3 dropPoint = GameManager.gameManagerInstance.player.transform.position + new Vector3(Random.Range(0.01f, 0.1f), 0.2f); // Then, we instantiate a default pickup, while keeping a reference to it. GameObject droppedPickupGO = Instantiate(InventoryManager.inventoryInstance.pickupPrefab, dropPoint, Quaternion.identity) as GameObject; // We then get a reference to it's pickup behaviour and set up it's properties to match the dropped ability PickupBehaviour droppedPickupBehaviour = droppedPickupGO.GetComponentInChildren <PickupBehaviour>(); droppedPickupBehaviour.AssignAbility(abilityBeingDropped); // Finally, we need to remove the ability from all relevant arrays if (abilityBeingDropped.abilityEquipped) // check if the ability is equipped { equippedAbilitiesController.UnequipAbility(abilityBeingDropped); // and if so, unequip it } InventoryManager.inventoryInstance.RemoveAbility(abilityBeingDropped); // then, we remove it from the inventory abilityInfoDisplay.AbilitySelected(abilityInfoDisplay.currentlySelectedAbility); // This ensures the UI and information that the info // panel displays is updated. }
public override void OnPickedUp(PickupBehaviour pickup, Pawn pawn) { pawn.Gun = pickup.GetComponent <GunBehaviour> (); pawn.Gun.team = pawn.team; pickup.transform.SetParent(pawn.transform); pickup.transform.position = pawn.GunHoldTransform.position; }
public override void OnPickedUp(PickupBehaviour pickup, Pawn pawn) { if (DEBUG) { Debug.Log("You Picked Up a Heath Pickup"); } pawn.pawnHealth.AddHealth(HealthAmount); Destroy(pickup.gameObject); }
private void Start() { pUp = GameObject.Find("PickupHandler").GetComponent <PickupBehaviour>(); col = gameObject.GetComponent <Collider>(); }
public abstract void OnPickedUp(PickupBehaviour pickup, Pawn pawn);
// Use this for initialization public void Initialize() { isInitialized = true; if (meshTransform) { meshTransform.localScale = new Vector3(1.0f, 1.0f, 1.0f) * GameplayConstants.tileEdgeSize; } bool gridRotate = false; switch (tileType) { case TileType.Custom: break; case TileType.Clear: break; case TileType.BumpersDefault: bumpers.Add(Instantiate(bumperPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.identity, transform)); bumpers.Add(Instantiate(bumperPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.Euler(0.0f, 0.0f, 180.0f), transform)); gridRotate = true; break; case TileType.Vault: Instantiate(vaultPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius, Quaternion.Euler(0.0f, 0.0f, subObjectAngle), transform); break; case TileType.FixedBumper: case TileType.FixedBumperClear: BumperBehaviour fixedBumper = Instantiate(bumperPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.Euler(0.0f, 0.0f, subObjectAngle), transform); fixedBumper.raiseBehaviour.isRaised = true; fixedBumper.isLockedByRule = true; bumpers.Add(fixedBumper); if (tileType == TileType.FixedBumper) { bumpers.Add(Instantiate(bumperPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.Euler(0.0f, 0.0f, subObjectAngle + 180.0f), transform)); } gridRotate = true; break; case TileType.BumperSingle: bumpers.Add(Instantiate(bumperPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.Euler(0.0f, 0.0f, subObjectAngle), transform)); break; case TileType.Block: Instantiate(blockPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius, Quaternion.identity, transform); break; case TileType.LockRed: subObjects.Add(Instantiate(lockRedPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.identity, transform).transform); break; case TileType.LockBlue: subObjects.Add(Instantiate(lockBluePrefab, transform.position + Vector3.back * GameplayConstants.ballRadius / 10, Quaternion.identity, transform).transform); break; default: Debug.LogError("Unexpected TileType found in TileBehaviour.Start()"); break; } if (gridRotate) { if ((gridPoint.x + gridPoint.y) % 2 == 1) { transform.Rotate(0.0f, 0.0f, 90.0f); } } if (pickupPrefab) { pickup = Instantiate(pickupPrefab, transform.position + Vector3.back * GameplayConstants.ballRadius, Quaternion.identity, transform); } }