Пример #1
0
 /// <summary>
 /// Create a structure for GameCharacter Tag. A Tag is a image or text displayed above GameCharacter
 /// </summary>
 /// <param Name="tagCharacter">GameCharacter to be Tagged</param>
 /// <param Name="tagText">Text to Tag</param>
 /// <param Name="tagIcon">Icon Name to Tag</param>
 /// <param Name="tagDuration">Duration of Tag</param>
 /// <param Name="tagFade">True if Tag should fade out</param>
 /// <param Name="tagIconDown">True if Tag should be display below Character</param>
 public Tag(GameCharacter tagCharacter, string tagText, string tagIcon, int tagDuration, bool tagFade, bool tagIconDown)
 {
     Character = tagCharacter;
     Text = tagText;
     Icon = tagIcon;
     Duration = tagDuration;
     IsIconFading = tagFade;
     IsIconDown = tagIconDown;
 }
Пример #2
0
 public Tag(GameCharacter tagCharacter, string tagText, string tagIcon, int tagDuration, bool tagFade, bool tagIconDown, Color tagColor, byte tagPosition)
 {
     Character = tagCharacter;
     Text = tagText;
     Icon = tagIcon;
     Duration = tagDuration;
     IsIconFading = tagFade;
     IsIconDown = tagIconDown;
     Position = tagPosition;
     TagColor = tagColor;
 }
Пример #3
0
        /// <summary>
        /// Sprite_Character Initialization
        /// </summary>
        /// <param Name="port">viewport</param>
        /// <param Name="_character">Character (GameCharacter)</param>
        public SpriteCharacter(Viewport port, GameCharacter _character) : base(port)
        {
            Character = _character;
            // Set the Character Size
            if (Character.TileId >= 384)
            {
                Character.Cw = 32;
                Character.Ch = 32;
            }
#if XBOX    // As Loading is slower on xbox you have to preload character's bitmap
            UpdateBitmap();
            UpdateCharacter();
#endif
        }
Пример #4
0
 /// <summary>
 /// True if this is within radius range
 /// </summary>
 /// <param Name="with">Character to be tested against</param>
 /// <param Name="radius">Radius in pixel</param>
 /// <param Name="type">True if Square range, otherwise circle</param>
 public bool ViewRange(GameCharacter with, int radius, bool squareRange)
 {
     int d=999999;
     if (with == this) return false;
     if (squareRange)
     {
         d = (X - with.X) + (Y - with.Y);
     }
     else
     {
         d = (int)(Math.Sqrt( (X - with.X)*(X-with.X) + (Y - with.Y)*(Y - with.Y) ));
     }
     return d<=radius;
 }
Пример #5
0
 /// <summary>
 /// True if this is facing ev
 /// </summary>
 /// <param Name="ev">Character to be tested against</param>
 /// <returns></returns>
 public bool IsFacingHard(GameCharacter ev)
 {
     int c = 0;
     int d = 0;
     switch (Dir)
     {
         case 2:
             c = ev.Y - Y;
             d = ev.X - X;
             return (Y < ev.Y) && (Math.Abs(c/(Math.Sqrt(d * d + c * c))) >= 0.75);
         case 4:
             c = X - ev.X;
             d = ev.Y - Y;
             return (X > ev.X) && (Math.Abs(c / (Math.Sqrt(d * d + c * c))) >= 0.75);
         case 6:
             c = ev.X - X;
             d = ev.Y - Y;
             return (X < ev.X) && (Math.Abs(c / (Math.Sqrt(d * d + c * c))) >= 0.75);
         case 8:
             c = Y - ev.Y;
             d = ev.X - X;
             return (Y > ev.Y) && (Math.Abs(c / (Math.Sqrt(d * d + c * c))) >= 0.75);
     }
     return false;
 }
Пример #6
0
 /// <summary>
 /// True if this is facing ev
 /// </summary>
 /// <param Name="ev">Character to be tested against</param>
 /// <returns></returns>
 public bool IsFacing(GameCharacter ev)
 {
     switch (Dir)
     {
         case 2:
             return (Y<ev.Y);
         case 4:
             return (X>ev.X);
         case 6:
             return (X<ev.X);
         case 8:
             return (Y>ev.Y);
     }
     return false;
 }
Пример #7
0
 /// Move away from GameCharacter
 /// </summary>
 /// <param Name="Character">Target GameCharacter</param>
 public void MoveAwayFromCharacter(GameCharacter character)
 {
     // Get difference in player coordinates
     int sx = X - character.X;
     int sy = Y - character.Y;
     // If coordinates are equal
     if (sx == 0 && sy == 0) return;
     // Get absolute value of difference
     int abs_sx = Math.Abs(sx);
     int abs_sy = Math.Abs(sy);
     // If horizontal and vertical distances are equal
     if (abs_sx == abs_sy)
     {
         // Increase one of them randomly by 32pixel
         if (InGame.Rnd.Next(2) == 0)
         {
             abs_sx += GeexEdit.TileSize;
             abs_sy += GeexEdit.TileSize;
         }
     }
     // If horizontal distance is longer
     if (abs_sx > abs_sy)
     {
         // Move away from player, prioritize left and right directions
         if (sx > 0)
         {
             MoveRight(true, GeexEdit.TileSize);
         }
         else
         {
             MoveLeft(true, GeexEdit.TileSize);
         }
         if (!IsMoving & sy != 0)
         {
             if (sy > 0)
             {
                 MoveDown(true, GeexEdit.TileSize);
             }
             else
             {
                 MoveUp(true, GeexEdit.TileSize);
             }
         }
     }
     // If vertical distance is longer
     else
     {
         // Move away from player, prioritize up and down directions
         if (sy > 0)
         {
             MoveDown(true, GeexEdit.TileSize);
         }
         else
         {
             MoveUp(true, GeexEdit.TileSize);
         }
         if (!IsMoving & sx != 0)
         {
             if (sx > 0)
             {
                 MoveRight(true, GeexEdit.TileSize);
             }
             else
             {
                 MoveLeft(true, GeexEdit.TileSize);
             }
         }
     }
 }
Пример #8
0
        /// <summary>
        /// Move toward a GameCharacter
        /// </summary>
        /// <param Name="Character">Target GameCharacter</param>
        public void MoveTowardCharacter(GameCharacter character)
        {
            // Get difference in player coordinates
            int sx = X - character.X;
            int sy = Y - character.Y;
            // If coordinates are equal
            if (sx == 0 && sy == 0) return;
            // Get absolute value of difference
            int abs_sx = Math.Abs(sx);
            int abs_sy = Math.Abs(sy);

            // If horizontal and vertical distances are equal
            if (abs_sx == abs_sy)
            {
                // Increase one of them randomly
                if (InGame.Rnd.Next(2) == 0)
                {
                    abs_sx += InGame.System.Speed[MoveSpeed];
                }
                else
                {
                    abs_sy += InGame.System.Speed[MoveSpeed];
                }
            }
            // If horizontal distance is longer
            if (abs_sx > abs_sy)
            {
                // Move towards player, prioritize left and right directions
                if (sx > 0)
                {
                    MoveLeft(true, InGame.System.Speed[MoveSpeed], true);
                }
                else
                {
                    MoveRight(true, InGame.System.Speed[MoveSpeed], true);
                }
                if (!IsMoving & sy != 0)
                {
                    if (sy > 0) { MoveUp(true, InGame.System.Speed[MoveSpeed], true); } else { MoveDown(true, InGame.System.Speed[MoveSpeed], true); }
                }
            }
            // If vertical distance is longer
            else
            {
                // Move towards player, prioritize up and down directions
                if (sy > 0) { MoveUp(true, InGame.System.Speed[MoveSpeed], true); } else { MoveDown(true, InGame.System.Speed[MoveSpeed], true); }
                if (!IsMoving & sx != 0)
                {
                    if (sx > 0) { MoveLeft(true, InGame.System.Speed[MoveSpeed], true); } else { MoveRight(true, InGame.System.Speed[MoveSpeed], true); }
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Change an ELOBject to a game_character array
 /// </summary>
 public GameCharacter[] ToCharacterArray()
 {
     switch (expr)
     {
         case "any:event":
             return InGame.Map.Events;
         case "any:character":
             GameCharacter[] temp = new GameCharacter[InGame.Map.Events.Length + 1];
             InGame.Map.Events.CopyTo(temp, 0);
             temp[InGame.Map.Events.Length] = InGame.Player;
             return temp;
         default:
             return null;
     }
 }
Пример #10
0
 /// <summary>
 /// Change GameEvent according to intParams
 /// </summary>
 /// <param Name="Character"></param>
 int ChangeGameEvent(ref GameCharacter character)
 {
     if (character != null)
     {
         switch (intParams[5])
         {
             case 0:  // x-coordinate
                 return character.X / GeexEdit.TileSize;
             case 1:  // y-coordinate
                 return (character.Y - InGame.Player.CollisionHeight / 2) / GeexEdit.TileSize;
             case 2:  // direction
                 return character.Dir;
             case 3:  // screen x-coordinate
                 return character.ScreenX;
             case 4:  // screen y-coordinate
                 return character.ScreenY;
             case 5:  // terrain tag
                 return character.TerrainTag;
         }
     }
     return 0;
 }