void Tap(SwipeController.SwipeType type) { if (type == SwipeController.SwipeType.Tap) { energy.AddEnergy(addeng); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.E)) { energy.AddEnergy(inventory.Consume()); } }
/// <summary> /// Sent when another object enters a trigger collider attached to this /// object (2D physics only). /// </summary> /// <param name="other">The other Collider2D involved in this collision.</param> void OnTriggerEnter2D(Collider2D other) { Energy e = other.gameObject.GetComponent <Energy>(); if (e != null) //checking if it is a ship { e.AddEnergy(energy); Destroy(gameObject); } }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "BeDestroyedObject" && transform.GetComponent <Rigidbody2D>().velocity != Vector2.zero) { Time.timeScale = 0.7f; shake.ShakeObject(); col.gameObject.GetComponent <BeDestroyedObject>().BeginDamage(1); energy.AddEnergy(25.0f); Time.timeScale = 1f; } }
public void MarkSafe(GameObject unit) { if (unit.GetComponent <CrabController>() != null) { unit.GetComponent <CrabController>().Safe(); en.AddEnergy(unit.GetComponent <CrabController>().giveFood()); if (!crabUnits.Contains(unit)) { crabUnits.Add(unit); } } }
private void StartDash() { if (Energy.CurrentEnergy >= dashEnergyCost) { foreach (GameObject actor in GameManager.Instance.actorsContainer.Keys) { if (actor.CompareTag("Enemy")) { actor.GetComponent <Collider2D>().isTrigger = true; } } Energy.AddEnergy(-dashEnergyCost); IsInvulnerable = true; isMovable = false; animator.SetTrigger("StartDash"); } }
public void PerformAction() { if (food != null) { Vector3 colliderPosition = blob.transform.position; colliderPosition.y += blob.transform.localScale.y / 2; Collider[] hitColliders = Physics.OverlapSphere(colliderPosition, 0.25F, 0x0100); // 0x0100 is layermask for layer 8 if (hitColliders.Any(x => x.gameObject.GetInstanceID() == food.GetInstanceID())) { energy.AddEnergy(food.GetComponent <Edible>().Bite(1)); food = null; blobMovement.Stop(); } } else if (!isWandering) { blobMovement.Stop(); } }
public IEnumerator PluginAnimation(Energy energy) { _isPlayingBlockingAnimation = true; _playerInput.enabled = false; _player.Stop(); _animator.SetTrigger("plugin"); yield return(new WaitForSeconds(pluginDuration)); // TODO: Animate energy energy.AddEnergy(energy.maxEnergy); yield return(new WaitForSeconds(chargeDuration - pluginDuration)); _animator.SetTrigger("unplug"); var unplugDuration = _animator.GetCurrentAnimatorStateInfo(0).length; yield return(new WaitForSeconds(unplugDuration)); _playerInput.enabled = true; _isPlayingBlockingAnimation = false; }
private void Update() { energy.AddEnergy(-Time.deltaTime); }
public void AddEnergy(float energy) { Energy.AddEnergy(energy); }