// Update is called once per frame void Update() { if (Pauzed.IsPauzed) { return; } if (spawnInvulnerability > 0) { spawnInvulnerability -= Time.deltaTime; return; } if (_stunnedTimer > 0) //TODO ALL enemies stunned first and hitcallback during stunned { _stunnedTimer -= Time.deltaTime; if (_stunnedTimer <= 0) { StopStunAnimation(); //STOP STUNNED ANIMATION } else { return; } } if (isClone) { return; } if (!_isFalling && _rigid.velocity.y < -0.5f) { _sheetAni.PlayAnimationUnC(FallingSprites); _isFalling = true; } else { if (_isFalling && _rigid.velocity.y >= 0) { _sheetAni.PlayAnimationUnC(WalkingSprites); _isFalling = false; } } EnemyUpdate(); if (transform.position.x == _lastXPos || Mathf.Abs(_rigid.velocity.x) < 0.1f) { faceRight = !faceRight; } if (_spriteR) { _spriteR.flipX = faceRight; } _lastXPos = transform.position.x; if (_rigid) { _rigid.velocity = new Vector2((faceRight ? 1.0f : -1.0f) * MoveSpeed, _rigid.velocity.y); } }
protected override void Pickup(GameObject player) { PlayerMovement mov = player.GetComponent <PlayerMovement>(); if (!mov) { mov = player.transform.parent.gameObject.GetComponent <PlayerMovement>(); } ScoreManager.instance.ChangeScore((int)mov.playerID, ScoreManager.instance.scoreMode == ScoreManager.ScoreMode.Health? -1 : 1); GameObject temp = new GameObject("Life animation"); temp.transform.position = transform.position; temp.AddComponent <SpriteRenderer>(); SheetAnimation SA = temp.AddComponent <SheetAnimation>(); float time = 1.5f; SA.PlayAnimationUnC("Powerups/Powers/LifeUp/Life", false, 8f / time); temp.AddComponent <DestroyAfterSeconds>().Seconds = time; ScoreManager.gameData.LivesPicked++; }