public override void Draw(TerraGuardian guardian)
 {
     if (Step == 2 && guardian.Inventory[ItemSlot].type > 0)
     {
         Vector2 ItemSpawnPosition = guardian.GetRightHandPosition(guardian.Base.ItemUseFrames[0]);
         if (Formally)
         {
             GuardianDrawData gdd = new GuardianDrawData(GuardianDrawData.TextureType.TGExtra, Main.itemTexture[guardian.Inventory[ItemSlot].type], ItemSpawnPosition - Main.screenPosition, null, Color.White);
             TerraGuardian.DrawBehind.Add(gdd);
         }
         else
         {
             float   AnimationPercentage = Time * (1f / 60);
             Vector2 Destination         = Vector2.Zero;
             if (player != null)
             {
                 Destination = player.Center;
             }
             else
             {
                 Destination = tg.CenterPosition;
             }
             ItemSpawnPosition = ItemSpawnPosition + (Destination - ItemSpawnPosition) * AnimationPercentage - Main.screenPosition;
             GuardianDrawData gdd = new GuardianDrawData(GuardianDrawData.TextureType.TGExtra, Main.itemTexture[guardian.Inventory[ItemSlot].type], ItemSpawnPosition, null, Color.White);
             TerraGuardian.DrawBehind.Add(gdd);
         }
     }
 }
Exemple #2
0
        public Vector2 GetHandPosition(TerraGuardian guardian, int AnimationFrame, HeldHand hand)
        {
            Vector2 HandPosition = guardian.Position;

            if ((hand == HeldHand.Right || hand == HeldHand.Both) && guardian.Base.DontUseRightHand)
            {
                hand = HeldHand.Left;
            }
            if ((hand == HeldHand.Left || hand == HeldHand.Both) && guardian.Base.DontUseLeftHand)
            {
                hand = HeldHand.Right;
            }
            switch (hand)
            {
            case HeldHand.Left:
                HandPosition += guardian.GetLeftHandPosition(AnimationFrame);
                break;

            case HeldHand.Right:
                HandPosition += guardian.GetRightHandPosition(AnimationFrame);
                break;

            case HeldHand.Both:
                HandPosition += guardian.GetBetweenHandsPosition(AnimationFrame);
                break;
            }
            return(HandPosition);
        }
        public override void Update(TerraGuardian guardian)
        {
            TerraGuardian ControlledGuardian = PlayerMod.PlayerControllingGuardian(PlayerToPlaceOnFloor) ? PlayerToPlaceOnFloor.GetModPlayer <PlayerMod>().Guardian : null;

            if (Time == 0 && guardian.PlayerMounted)
            {
                guardian.ToggleMount(false, false);
            }
            if (guardian.ReverseMount || guardian.Base.DontUseRightHand || guardian.UsingFurniture)
            {
                InUse = false;
            }
            else
            {
                FocusCameraOnGuardian = true;
                if (Time >= 20)
                {
                    InUse = false;
                    if (ControlledGuardian == null)
                    {
                        PlayerToPlaceOnFloor.position.X = guardian.Position.X - PlayerToPlaceOnFloor.width * 0.5f;
                        PlayerToPlaceOnFloor.position.Y = guardian.Position.Y - PlayerToPlaceOnFloor.height;
                        PlayerToPlaceOnFloor.velocity   = guardian.Velocity;
                        PlayerToPlaceOnFloor.fallStart  = (int)PlayerToPlaceOnFloor.position.Y / 16;
                    }
                    else
                    {
                        ControlledGuardian.Position = guardian.Position;
                        ControlledGuardian.Velocity = guardian.Velocity;
                        ControlledGuardian.SetFallStart();
                    }
                }
                else
                {
                    int AnimFrame = guardian.Base.ItemUseFrames[0];
                    if (Time >= 15)
                    {
                        AnimFrame = guardian.Base.ItemUseFrames[3];
                    }
                    else if (Time >= 10)
                    {
                        AnimFrame = guardian.Base.ItemUseFrames[2];
                    }
                    else if (Time >= 5)
                    {
                        AnimFrame = guardian.Base.ItemUseFrames[1];
                    }
                    int HPosX, HPosY;
                    guardian.GetRightHandPosition(AnimFrame, out HPosX, out HPosY);
                    Vector2 HandPosition = guardian.Position;
                    HandPosition.X += HPosX;
                    HandPosition.Y += HPosY;
                    if (ControlledGuardian == null)
                    {
                        HandPosition.X -= PlayerToPlaceOnFloor.width * 0.5f;
                        HandPosition.Y -= PlayerToPlaceOnFloor.height * 0.5f;
                        PlayerToPlaceOnFloor.position   = HandPosition;
                        PlayerToPlaceOnFloor.fallStart  = (int)PlayerToPlaceOnFloor.position.Y / 16;
                        PlayerToPlaceOnFloor.velocity.X = 0;
                        PlayerToPlaceOnFloor.velocity.Y = -Player.defaultGravity;
                        if (PlayerToPlaceOnFloor.itemAnimation == 0)
                        {
                            PlayerToPlaceOnFloor.direction = guardian.Direction;
                        }
                    }
                    else
                    {
                        HandPosition.Y += ControlledGuardian.Height * 0.5f;
                        ControlledGuardian.Position = HandPosition;
                        ControlledGuardian.SetFallStart();
                        ControlledGuardian.Velocity.X = 0;
                        ControlledGuardian.Velocity.Y = -ControlledGuardian.Mass;
                        if (ControlledGuardian.ItemAnimationTime == 0)
                        {
                            ControlledGuardian.Direction = guardian.Direction;
                        }
                    }
                }
            }
            guardian.MoveRight = PlayerToPlaceOnFloor.controlRight;
            guardian.MoveLeft  = PlayerToPlaceOnFloor.controlLeft;
            guardian.MoveUp    = PlayerToPlaceOnFloor.controlUp;
            guardian.MoveDown  = PlayerToPlaceOnFloor.controlDown;
            guardian.Jump      = PlayerToPlaceOnFloor.controlJump;
        }
Exemple #4
0
        public override void Update(TerraGuardian guardian)
        {
            TerraGuardian ControlledGuardian = PlayerMod.PlayerControllingGuardian(PlayerToPickup) ? PlayerToPickup.GetModPlayer <PlayerMod>().Guardian : null;

            if (Step == 0) //Try reaching player
            {
                if (guardian.PlayerMounted)
                {
                    InUse = false;
                    return;
                }
                IgnoreCombat = true;
                if (!guardian.IsBeingPulledByPlayer)
                {
                    if (TryReachingPlayer(guardian, PlayerToPickup))
                    {
                        ChangeStep();
                    }
                    else
                    {
                        if (guardian.furniturex > -1)
                        {
                            guardian.LeaveFurniture();
                        }
                    }
                }
            }
            else //Pickup Player animation.
            {
                BlockOffHandUsage = true;
                //guardian.PlayerMounted = true;
                if (guardian.ReverseMount || guardian.Base.DontUseRightHand || guardian.UsingFurniture)
                {
                    guardian.ToggleMount(false, false);
                    InUse = false;
                }
                else
                {
                    FocusCameraOnGuardian = true;
                    if (Time >= 20)
                    {
                        guardian.ToggleMount(false, false);
                        InUse = false;
                    }
                    else
                    {
                        if (PlayerToPickup.mount.Active)
                        {
                            PlayerToPickup.mount.Dismount(PlayerToPickup);
                        }
                        int AnimFrame = guardian.Base.ItemUseFrames[3];
                        if (Time >= 15)
                        {
                            AnimFrame = guardian.Base.ItemUseFrames[0];
                        }
                        else if (Time >= 10)
                        {
                            AnimFrame = guardian.Base.ItemUseFrames[1];
                        }
                        else if (Time >= 5)
                        {
                            AnimFrame = guardian.Base.ItemUseFrames[2];
                        }
                        int HPosX, HPosY;
                        guardian.GetRightHandPosition(AnimFrame, out HPosX, out HPosY);
                        Vector2 HandPosition = guardian.Position;
                        HandPosition.X += HPosX;
                        HandPosition.Y += HPosY;
                        if (ControlledGuardian == null)
                        {
                            HandPosition.X           -= PlayerToPickup.width * 0.5f;
                            HandPosition.Y           -= PlayerToPickup.height * 0.5f;
                            PlayerToPickup.position   = HandPosition;
                            PlayerToPickup.fallStart  = (int)PlayerToPickup.position.Y / 16;
                            PlayerToPickup.velocity.X = 0;
                            PlayerToPickup.velocity.Y = -Player.defaultGravity;
                            if (PlayerToPickup.itemAnimation == 0)
                            {
                                PlayerToPickup.direction = guardian.Direction;
                            }
                        }
                        else
                        {
                            HandPosition.Y += ControlledGuardian.Height * 0.5f;
                            ControlledGuardian.Position = HandPosition;
                            ControlledGuardian.SetFallStart();
                            ControlledGuardian.Velocity.X = 0;
                            ControlledGuardian.Velocity.Y = -ControlledGuardian.Mass;
                            if (ControlledGuardian.ItemAnimationTime == 0)
                            {
                                ControlledGuardian.Direction = guardian.Direction;
                            }
                        }
                    }
                }
                guardian.MoveRight = PlayerToPickup.controlRight;
                guardian.MoveLeft  = PlayerToPickup.controlLeft;
                guardian.MoveUp    = PlayerToPickup.controlUp;
                guardian.MoveDown  = PlayerToPickup.controlDown;
                guardian.Jump      = PlayerToPickup.controlJump;
            }
        }