void OnCollisionEnter(Collision collider) { #region obstacles if (collider.gameObject.tag == "obstacles") { SnakeState = SnakeStatus.Snakedead; //check if he made new high score savePlayerdata(); //set the right high score UIManager.Instance.SetHighScore(GetPlayerData()); UIManager.Instance.ArrowPanle.SetActive(false); UIManager.Instance.OpenPanel(0); } #endregion #region Apple else if (collider.gameObject.tag == "Apple") { PlayerScore++; UIManager.Instance.SetScore(PlayerScore); FruitsController.Instance.PlayAppleSound(); Destroy(collider.gameObject); FruitsController.Instance.GenerateApple(); GetComponent <SnakeMotion>().AddSnakPart(); } #endregion }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.TryGetComponent <Player>(out Player player)) { _currentStatus = SnakeStatus.Atack; } }
public Snake(string id, int initialLength, Point initialPosition, SnakeStatus initialDirection, int maxWeight, Size boardSize) { Id = id; _desiredLength = Math.Max(1, initialLength); Status = initialDirection; _cells.Add(initialPosition); _boardSize = boardSize; MaxWeight = maxWeight; ResetWeight(); }
public BigSnake(object sprite, Vector2 speed, Vector2 locate, float enemySize, float enemySize2, AIBase.ID id) : base(sprite, speed, locate, 0, enemySize, enemySize2, 0, id) { CurrentStatus = HeadStatus.Good; Head = new List<Texture2D>(); HeadHP = new List<Texture2D>(); BodyNodeList = new List<BodyNode>(); this.Name = AIBase.BossID.SnakeBoss; this.CurrentSnakeStatus = SnakeStatus.Chase; this.CurrentCharge = 0; this.CurrentFreeze = 0; }
public StatusChangedEventArgs(SnakeStatus prevStatus) { PrevStatus = prevStatus; }
private void StunnedTimer_Elapsed(object sender, ElapsedEventArgs e) { _status &= ~SnakeStatus.Stunned; Status |= SnakeStatus.AfterStunned; }
private void SuperTimer_Elapsed(object sender, ElapsedEventArgs e) { _status &= ~SnakeStatus.Super; }
public override void Update(GameTime gameTime) { switch (CurrentSnakeStatus) { case SnakeStatus.Dead: if (this.Color.A != 0) this.Color.A -= 15; else { GameCommands.Enqueue( "clear" ); AIBase.EnemyList.Remove( this ); } break; case SnakeStatus.Notail: this.Speed = AIBase.Player.Locate - this.Locate; this.Speed.Length = this.Speed.Length/3 + 320; this.PostionGenerate(gameTime); this.LocateConfirm(); if ((this.Locate - AIBase.Player.Locate).Length() < 180) { this.CurrentSnakeStatus = SnakeStatus.NotailCharge; } break; case SnakeStatus.NotailCharge: if(this.CurrentCharge <= BigSnake.FreezeTime) { this.Speed = AIBase.Player.Locate - this.Locate; this.Speed.Length = this.Speed.Length/2; this.PostionGenerate(gameTime); this.LocateConfirm(); this.CurrentCharge++; }else { this.CurrentFreeze = 0; this.CurrentSnakeStatus = SnakeStatus.NotailAttack; } break; case SnakeStatus.NotailAttack: if (this.AttackIndex < SnakeAttackRange.Length) { this.Postion += CoreUtilities.GetVector(this.SnakeAttackRange[this.AttackIndex], this.Speed.Radian); this.AttackIndex++; if (!AIBase.SenceManager.IntersectPixels(this.Postion, 40)) this.LocateConfirm(); } else { this.AttackIndex = 0; this.CurrentSnakeStatus = SnakeStatus.NotailFreeze; AlreadyAttacked = true ; } if ((this.Locate - AIBase.Player.Locate).Length() <= 80) { if (AIBase.Player.Status != AIBase.Status.Freeze) { AIBase.Player.Status = AIBase.Status.Freeze; AIBase.Player.BeAttackedRadian = this.Rotation; } } break; case SnakeStatus.NotailFreeze: if ((this.Postion - AIBase.Player.Postion).Length() < 80 && AIBase.Player.Status == AIBase.Status.Attck) { if (AlreadyAttacked) { if (this.CurrentStatus == HeadStatus.Good) { this.CurrentStatus = HeadStatus.Weak; AlreadyAttacked = false; } else if (this.CurrentStatus == HeadStatus.Weak) { this.CurrentStatus = HeadStatus.Bad; AlreadyAttacked = false; } else if (this.CurrentStatus == HeadStatus.Bad) { this.CurrentSnakeStatus = SnakeStatus.Dead; AlreadyAttacked = false; } } } if (this.CurrentFreeze < 2 * BigSnake.FreezeTime) { this.CurrentFreeze++; } else { this.CurrentFreeze = 0; if (this.CurrentSnakeStatus != SnakeStatus.Dead) this.CurrentSnakeStatus = SnakeStatus.Notail; } break; case SnakeStatus.AttackII: if (this.AttackIndex < this.SnakeAttackRange.Length - 1) { this.AttackIndex++; this.Postion += CoreUtilities.GetVector(this.SnakeAttackRange[this.AttackIndex], this.Speed.Radian); this.LocateConfirm(); if ((this.Locate - AIBase.Player.Locate).Length() <= 50) { AIBase.Player.Status = AIBase.Status.Freeze; AIBase.Player.BeAttackedRadian = this.Rotation; } } else { this.AttackIndex = 0; this.CurrentSnakeStatus = SnakeStatus.Freeze; } break; case SnakeStatus.Chase: this.Speed = AIBase.Player.Locate - this.Locate; this.Speed.Length = this.Speed.Length / 3 + 320; this.Postion = AIBase.SenceManager.MoveTest(this.Locate, this.Speed, (float)gameTime.ElapsedGameTime.TotalSeconds); this.LocateConfirm(); this.m_rotate = Speed.Radian; if ((this.Locate - AIBase.Player.Locate).Length() >= 260) { this.CurrentSnakeStatus = SnakeStatus.Charge; } if ((this.Locate - AIBase.Player.Locate).Length() <= 180) { this.CurrentSnakeStatus = SnakeStatus.AttackII; } break; case SnakeStatus.Charge: if (this.CurrentCharge <= BigSnake.ChargeTime) { this.CurrentCharge++; this.Speed = AIBase.Player.Locate - this.Locate; this.m_rotate = Speed.Radian; this.Rotate = m_rotate; } else { this.CurrentCharge = 0; this.CurrentSnakeStatus = SnakeStatus.Attack; this.Speed = AIBase.Player.Locate - this.Locate; this.Speed.Length = this.Speed.Length / 3 + 320; } break; case SnakeStatus.Attack: this.PostionGenerate(gameTime); if (!AIBase.SenceManager.IntersectPixels(this.Postion, (int)(this.EnemySize * 100 / 2))) { this.LocateConfirm(); } else { this.CurrentSnakeStatus = SnakeStatus.Freeze; } if ((this.Locate - AIBase.Player.Locate).Length() < 80) { AIBase.Player.Status = AIBase.Status.Freeze; AIBase.Player.BeAttackedRadian = this.Rotation; } break; case SnakeStatus.Freeze: if (this.CurrentFreeze <= BigSnake.FreezeTime) { this.CurrentFreeze++; } else { this.CurrentFreeze = 0; this.CurrentSnakeStatus = SnakeStatus.Chase; } break; } foreach (var ptr in BodyNodeList) { ptr.Update(gameTime, this.Locate, this.BodyNodeList, this); ptr.RightGlass.GeneratePostion(ptr.Postion, ptr.Rotation); ptr.LeftGlass.GeneratePostion(ptr.Postion, ptr.Rotation); if (ptr.NodeStatus != NodeStatus.Bad) { ptr.LeftGlass.Update(gameTime); ptr.RightGlass.Update(gameTime); } } }