private void Awake() { this._enemiesInRange = new List <GameObject>(); this._shockCooldown = new Cooldown(); this.CamouflageModeActive = false; m_stunnedCooldown.Start(); }
void GotoTransition() { gameState = GameState.Transition; gui.Goto(gameState); gui.UpdateAlpha(1f); if (playerHurted == false) { gui.SetRandomMessage(); ClearLevel(); } cooldownTransition.Start(); }
private void Update() { if (cdTickDamage.IsFinished) { for (int i = 0; i < enemies.Count; i++) { if (enemies[i] != null) { enemies[i].GetComponent <EnemyReceiveDamage>().Damage = damage; } else { enemies.Remove(enemies[i]); i--; } } cdTickDamage.Start(); } if (cdLifeTime.IsFinished) { Destroy(gameObject); } }
public void Fire() { if (!m_elephantControl.aiming || !cooldown.IsOver() || ammo < 1) { return; } ammo -= 1; cooldown.Start(); //transform the offset from wolrd location to local Vector3 worldOffset = transform.rotation * m_offset; Vector3 offsetPosition = transform.position + worldOffset; if (m_shootOrigin) { offsetPosition = m_shootOrigin.position; } //Instantiate a clone of the given asset GameObject clone = Instantiate(m_peanutPrefab, offsetPosition, transform.rotation); //set the velocity of the clone clone.GetComponent <Rigidbody>().velocity = transform.TransformDirection(Vector3.forward * m_velocity); if (peanutWasShot != null) { peanutWasShot.Invoke(); } //Destroy clone after x seconds Destroy(clone, m_lifeSpan); }
public void Upgrade(int damage, float range, float newCD) { projectile.GetComponent <ProjectileMovement>().SetDamage = damage; attackRange = range; cdShoot = new Cooldown(newCD); cdShoot.Start(); }
public virtual void Fire() { if (Cooldown.IsActive) { //Debug.Log(name + " is on cooldown.", this); return; } //Debug.Log("Fire " + name); if (Ammunition != null) { // Instantiate Projectile projectile = Instantiate(Ammunition, Muzzle.position, Muzzle.rotation); // Add force projectile.GetComponent <Rigidbody>()?.AddForce(GetComponentInParent <Rigidbody>().velocity *ParentVelocityInfluence + Muzzle.forward * ProjectileSpeed, forceMode); projectile.Owner = GetComponentInParent <Player>(); if (ServerBehaviour.HasActiveInstance()) { ServerBehaviour.Instance.projectiles.Add(projectile); } StartCoroutine(Cooldown.Start()); } }
public void Fire() { CheckAmmo(); if (Cooldown.IsReady() && Reload.IsReady() && _magazineAmmo >= 0) { //Functionality Cooldown.Start(); var dir = (float)Math.Atan2(_player.FacingAngle.Y, _player.FacingAngle.X); var x = (float)(position.X + Math.Cos(localRotation) * _barrelOffset.X + Math.Cos(localRotation) * _barrelOffset.Y); var y = (float)(position.Y + Math.Sin(localRotation) * _barrelOffset.Y + Math.Sin(localRotation) * _barrelOffset.X); for (float i = 0; i < _bulletCount; i++) { var direction = dir + (1 - _accuracy) * Nez.Random.minusOneToOne() / 2 + (1 - _accuracy) * _player.Velocity.Length() * Nez.Random.minusOneToOne() + ((i * 2 - _bulletCount) * _bulletSpread / _bulletCount); Bullet.Create(_player, x, y, direction, _params.BulletParameters); } _magazineAmmo--; //Animation _renderer?.Fire(); } }
void Start() { gui = GameObject.FindObjectOfType <GUI>(); collisionDetector = GameObject.FindObjectOfType <CollisionDetector>(); collisionDetector.collisionDelegate = Collision; collectibleList = new List <Collectible>(); indexGridArray = new int[Grid.width * Grid.height]; for (int i = 0; i < indexGridArray.Length; ++i) { indexGridArray[i] = i; } UpdateResolution(); cooldownTransition = new Cooldown(5f); cooldownChilling = new Cooldown(0.5f); cooldownChilling.Start(); startButton = new Button(new Vector2(0.5f, 0.5f)); startButton.UpdateSize(0.3f); // AddCollectible(startButton); Cursor.visible = false; GotoChilling(); }
// Start is called before the first frame update void Start() { grassCanGo = new List <Tile>(); createMap = GameObject.FindGameObjectWithTag("GameController").GetComponent <CreateMap>(); spawnHumanCD = new Cooldown(timeToSpawnHuman); spawnHumanCD.Start(); transformToCityCD = new Cooldown(timeToTransformToCity); transformToCityCD.Stop(); spriteRender = GetComponent <SpriteRenderer>(); transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.x, transform.rotation.y + 180, transform.rotation.z)); if (desert.Length > 0) { rnd = (int)Random.Range(0, desert.Length); spriteRender.material = desert[rnd]; } else { spriteRender.color = Color.yellow; } }
private bool IsMouseInRange(out List <GameObject> miceInRange) { miceInRange = new List <GameObject>(); bool result = false; Collider[] hits = Physics.OverlapSphere(transform.position + _elephantEyeOffset, _mouseReactDistance); foreach (Collider coll in hits) { if (coll.gameObject.CompareTag(_mouseTag)) { RaycastHit hit; Vector3 direction = coll.gameObject.transform.position - (transform.position + _elephantEyeOffset); bool hitSomething = Physics.Raycast(transform.position + _elephantEyeOffset, direction, out hit, _mouseReactDistance); if (hitSomething && hit.collider.gameObject.CompareTag(_mouseTag)) { #if UNITY_EDITOR Debug.DrawLine(transform.position + _elephantEyeOffset, hit.collider.gameObject.transform.position, Color.white); #endif _shockCooldown.timeInSeconds = _shockedCooldownMS / 1000.0f; _shockCooldown.Start(); miceInRange.Add(coll.gameObject); result = true; } #if UNITY_EDITOR else if (hitSomething) { Debug.DrawLine(transform.position + _elephantEyeOffset, hit.point, Color.red); } #endif } } return(result); }
private void Start() { moneyPerSec = new Cooldown(1); moneyPerSec.Start(); textMoney.text = money.ToString(); }
private void Update() { if (moneyPerSec.IsFinished) { //Money += 1; moneyPerSec.Start(); } }
private void GoToForest() { if (Vector2.Distance(destiny.position, transform.position) < 0.1f) { isInTheForest = true; destroyForestCD.Start(); } transform.position = Vector2.MoveTowards(transform.position, destiny.position, Time.deltaTime * speed); }
// Start is called before the first frame update void Start() { col = GetComponent <BoxCollider2D>(); destroyForestCD = new Cooldown(timeToDestroyForest); waitToGo = new Cooldown(0.5f); waitToGo.Start(); destroyForestCD.Stop(); }
IEnumerator AttackGrenade() { EnemyMovement.FaceTarget(transform, targetDistance.Target); grenadeAttack.Execute("Player"); yield return(new WaitForSeconds(1.5f)); grenadeAttackCooldown.Start(); }
/// <summary> /// Start the power up /// </summary> public void Start() { active = true; ActivateUI(); cd.Start(); UpdateText(); }
private void Update() { if (cdShoot.IsFinished) { if (Shoot()) { cdShoot.Start(); } } }
private void Start() { enemies = new List <GameObject>(); cdLifeTime = new Cooldown(lifeTime); cdTickDamage = new Cooldown(tickDamage); cdLifeTime.Start(); cdTickDamage.Start(); }
public void EndRound() { _gameState = GameState.Ending; Time.timeScale = 0.8f; _transitionDelay.Start(); var sepia = _broScene.addPostProcessor(new VignettePostProcessor(5)); sepia.effect = new SepiaEffect(); _camera.SetWinMode(true); }
public override void TryToActivate(Direction direction) { if (_cooldown.IsOnCoolDown.Value) { return; } StartDash(direction); _cooldown.Start(); OnCooldown = true; }
/// <summary> /// Creating and invoking a start for the cooldown /// </summary> /// <param name="cooldown">Cooldown</param> /// <exception cref="ArgumentException">Cooldown is null</exception> public void CreateCooldown(Cooldown cooldown) { if (cooldown == null) { Out.QuickLog("Something went wrong with creating cooldown", LogKeys.ERROR_LOG); throw new ArgumentException("Cannot add cooldown, Cooldown is null, error in manager"); } ServerController.Get <CooldownController>().AddCooldown(cooldown); cooldown.Start(); }
// Start is called before the first frame update void Start() { canLose = new Cooldown(5f); canLose.Start(); createMap = GetComponent <CreateMap>(); pause = GetComponent <PauseController>(); score = GetComponent <Score>(); playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>(); }
IEnumerator WalkBackATinyBit() { EnemyMovement.FaceTarget(transform, targetDistance.Target); float startTime = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup < startTime + 24f / 30f) { physic.MoveForward(-0.1f); yield return(new WaitForEndOfFrame()); } walkBackCooldown.Start(); }
public override void PlaceOn(GameObject square, GameObject placingPlayer) { SwapBombSFX = GameManager.instance.sfx["SwapBombSFX"]; BombTickSFX = GameManager.instance.sfx["BombTickSFX"]; base.PlaceOn(square, placingPlayer); onGrid = true; gc = square.transform.parent.gameObject.GetComponent <GridControl>(); if (fuse == null) { fuse = new Cooldown(fuseTime); } fuse.Start(); BombTickSFX.Play(); }
private void TryShoot() { if (enemyToAttack != null && Vector2.Distance(enemyToAttack.transform.position, transform.position) <= attackRange && enemyToAttack.GetComponent <EnemyReceiveDamage>().IsActive) { cdShoot.Start(); anim.SetTrigger("Shoot"); } else { FindEnemies(); } }
private void CastFireBall() { if (!fireballCooldown.IsInProgress()) { fireballCooldown.Start(); GameObject fireball = Instantiate(fireballPrefab, spellSpawn.position, spellSpawn.rotation); fireball.GetComponent <Rigidbody>().velocity = fireball.transform.forward * fireballSpeed; Destroy(fireball, fireballExistanceTime); } else { Debug.Log("Fireball is on cooldown. Remaining " + fireballCooldown.GetRemainingValue()); } }
private void Awake() { Time.timeScale = 1f; //Need this if the scene comes from a pause if (!useDelay) // if don't want to force a loading { StartCoroutine(LoadingScreen()); } else { //start the cooldown timer randomly, to pass the feel it is real delayCD = new Cooldown(Random.Range(0.1f, delayToLoad)); delayCD.Start(); } }
IEnumerator StunRoutine(Interactor interactor) { ElephantMovement movement = interactor.GetComponent <ElephantMovement>(); if (movement) { movement.Punch(); } if (OnStun != null) { OnStun(new StunEventData(interactor.gameObject, gameObject)); } var stateEnemy = GetComponent <StatePatternEnemy>(); var navMeshAgent = GetComponent <NavMeshAgent>(); stateEnemy.StopMovement(); stateEnemy.enabled = false; navMeshAgent.enabled = false; interactor.GetComponent <AudioSource>().PlayOneShot(stunEnemyHitSound); if (stunIndicatorDestroyComp == null) { // Spawn stun indicator GameObject go = Instantiate <GameObject>(stunIndicatorPrefab); go.transform.parent = transform; go.transform.localPosition = stunIndicatorOffset; stunIndicatorDestroyComp = go.GetComponent <FadeAndDestroy>(); stunIndicatorDestroyComp.FadeInOutAndDestroy(0.15f, m_stunDuration.timeInSeconds - 0.5f, 0.35f); } else { stunIndicatorDestroyComp.ResetDuration(); } while (!m_stunDuration.IsOver()) { m_stunDuration.Update(Time.deltaTime); yield return(null); } m_stunDuration.Start(); stateEnemy.enabled = true; navMeshAgent.enabled = true; m_stunRoutine = null; stunIndicatorDestroyComp = null; }
private void Fly() { if (cd_seekAgain.IsFinished) { UpdatePath(); cd_seekAgain.Start(); } if (flyPath == null || Vector2.Distance(rb.position, playerTransform.position) >= 20 /* if the enemy is too far away, do nothig*/ || currentWaypoint >= flyPath.vectorPath.Count /*if the enemy reachs the final waypoint*/) { return; } // the enemy only will go after the player if it can "see" him if (Vector2.Distance(rb.position, playerTransform.position) <= 6) { transform.position = Vector2.MoveTowards(rb.position, (Vector2)flyPath.vectorPath[currentWaypoint], control.maxSpeed * Time.deltaTime); float distance = Vector2.Distance(rb.position, flyPath.vectorPath[currentWaypoint]); if (distance <= pickNextWaypointDist) { currentWaypoint++; } Vector2 t = (Vector2)flyPath.vectorPath[currentWaypoint]; if (t.x < rb.position.x) { transform.localScale = originalScale; } else { transform.localScale = originalScale * new Vector2(-1, 1); } } // Else, the enemy will fly like a real fly else { float minMax = 1f; idleTarget = (new Vector2(Random.Range(-minMax, minMax), Random.Range(-minMax, minMax))) + rb.position; transform.position = Vector2.MoveTowards(rb.position, idleTarget, control.maxSpeed * Time.deltaTime); } }
void OnCollisionEnter2D(Collision2D collision) { var player = collision.gameObject.GetComponent <PlayerController>(); if (player != null) { var ev = Schedule <PlayerEnemyCollision>(); ev.player = player; ev.enemy = this; if (canFly) { cd_comeBack.Start(); } } }
void Start() { gui = GameObject.FindObjectOfType<GUI>(); collisionDetector = GameObject.FindObjectOfType<CollisionDetector>(); collisionDetector.collisionDelegate = Collision; collectibleList = new List<Collectible>(); indexGridArray = new int[Grid.width * Grid.height]; for (int i = 0; i < indexGridArray.Length; ++i) { indexGridArray[i] = i; } UpdateResolution(); cooldownTransition = new Cooldown(5f); cooldownChilling = new Cooldown(0.5f); cooldownChilling.Start(); startButton = new Button(new Vector2(0.5f, 0.5f)); startButton.UpdateSize(0.3f); // AddCollectible(startButton); Cursor.visible = false; GotoChilling(); }