Example #1
0
        public override void Update(GameTime gameTime)
        {
            if (!Communicator.CanDo(Id))
            {
                _idle = true;
            }

            SetAnimations();

            setComplexAnimations();

            _animationManager.Update(gameTime, false);

            Retrieve();

            Position += Velocity;

            UpdateMiscs();

            Velocity.X = 0;
        }
Example #2
0
        protected virtual void SetAnimations()
        {
            string[] chain;
            int      code;

            if (_air)
            {
                Velocity += Acceleration;
                if (Position.Y >= _relativePos)
                {
                    _air     = false;
                    Velocity = Vector2.Zero;
                    if (isMain)
                    {
                        Communicator.SendEndofAir();
                    }
                    bools[0] = false;
                }
            }

            if (!_stun)
            {
                if (_idle && !Communicator.CanDo(Id))
                {
                    if (_direction)
                    {
                        _animationManager.Play(_animations["Idle_Right"]);
                    }
                    else
                    {
                        _animationManager.Play(_animations["Idle_Left"]);
                    }
                    _idle = !_idle;
                }
                else
                {
                    if (Communicator.CanDo(Id))
                    {
                        chain = Communicator.GetAction(Id);
                        code  = int.Parse(chain[0]);
                        switch (code)
                        {
                        case 909:
                            Game1.vicCount++;
                            Game1.btnVictory.Text.Text = "Victory! You have slain the #" + Game1.vicCount + " Enemy.";
                            Game1.btnVictory.IsHidden  = false;
                            break;

                        case 500:
                            _hurt = true;
                            healthBar.CurrentValue += 10;
                            break;

                        case 200:     // move
                            if (chain[2] == "r")
                            {
                                _animationManager.Play(_animations["Run_Right"]);
                                Velocity.X = Champion.Speed;
                                _direction = true;
                            }
                            else
                            {
                                _animationManager.Play(_animations["Run_Left"]);
                                Velocity.X = -Champion.Speed;
                                _direction = false;
                            }
                            break;

                        case 201:     // attack1
                            _attack1 = true;
                            break;

                        case 202:     // attack2
                            _attack2 = true;
                            break;

                        case 203:     // jump
                            _idle        = false;
                            _air         = true;
                            _relativePos = Position.Y;
                            Velocity.Y   = -Champion.Speed - 20f;
                            break;
                        }
                    }
                }
            }
        }