Ejemplo n.º 1
0
        private void OnCollisionDetected(OnCollisionDetected ev)
        {
            switch (m_slimeForms)
            {
            case SlimeForms.NORMAL:
                if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left)
                {
                    m_slimeForms = SlimeForms.SEMI_STRETCHED_V;
                }
                else if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down)
                {
                    m_slimeForms = SlimeForms.SEMI_STRECHED_H;
                }
                break;

            case SlimeForms.SEMI_STRECHED_H:
                if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left)
                {
                    m_slimeForms = SlimeForms.NORMAL;
                }
                else if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down)
                {
                    m_slimeForms = SlimeForms.FULL_STRETCHED_H;
                }
                break;

            case SlimeForms.FULL_STRETCHED_H:
                if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left)
                {
                    m_slimeForms = SlimeForms.SEMI_STRECHED_H;
                }
                break;

            case SlimeForms.SEMI_STRETCHED_V:
                if (ev.CurrentDirection == Vector2.right || ev.CurrentDirection == Vector2.left)
                {
                    m_slimeForms = SlimeForms.FULL_STRETCHED_V;
                }
                else if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down)
                {
                    m_slimeForms = SlimeForms.NORMAL;
                }
                break;

            case SlimeForms.FULL_STRETCHED_V:
                if (ev.CurrentDirection == Vector2.up || ev.CurrentDirection == Vector2.down)
                {
                    m_slimeForms = SlimeForms.SEMI_STRETCHED_V;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            ev.OnFinishAnimation?.Invoke();
        }
Ejemplo n.º 2
0
        public void Update(TimeSpan elapsed)
        {
            for (var i = 0; i < _collidables.Count; i++)
            {
                var collidable = _collidables[i];
                for (var j = 0; j < _collidables.Count; j++)
                {
                    var otherCollidable = _collidables[j];

                    if (IsCollisionDetected(collidable, otherCollidable))
                    {
                        OnCollisionDetected?.Invoke(this, collidable, otherCollidable);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void OnCollision(CollisionEventArgs collisionInfo)
 {
     OnCollisionDetected?.Invoke(collisionInfo);
 }