Beispiel #1
0
 public static void SendMoveReportMsg(Character player)
 {
     ProjectXServer.Messages.PlayerPositioReport msg = new ProjectXServer.Messages.PlayerPositioReport();
     msg.Position = new float[2];
     msg.Position[0] = player.Position.X;
     msg.Position[1] = player.Position.Y;
     //ojectXServer.Messages.ProtobufAdapter.Send(clientchannel, msg);
     Beetle.ProtoBufAdapter.MessageAdapter.Send(clientchannel, msg);
 }
Beispiel #2
0
 public static void SendRequestMovementMsg(Character player)
 {
     ProjectXServer.Messages.PlayerMoveRequest msg = new ProjectXServer.Messages.PlayerMoveRequest();
     msg.Target = new float[2];
     msg.Target[0] = player.Target.X;
     msg.Target[1] = player.Target.Y;
     msg.Position = new float[2];
     msg.Position[0] = player.Position.X;
     msg.Position[1] = player.Position.Y;
     //ProjectXServer.Messages.ProtobufAdapter.Send(clientchannel, msg);
     Beetle.ProtoBufAdapter.MessageAdapter.Send(clientchannel, msg);
 }
Beispiel #3
0
 public void HighLightCharacterByPoint(int _x, int _y)
 {
     int x = _x + (int)viewport.X;
     int y = _y + (int)viewport.Y;
     Character host = null;
     if (state == SceneState.Battle)
     {
         /*if (player.Operate != Character.OperateType.None)
         {
             if (_hostCharacter != null)
             {
                 _hostCharacter.Picture.HighLight = false;
                 _hostCharacter = null;
             }
             return;
         }*/
     }
     for (int i = 0; i < characters.Count; ++i)
     {
         if (characters[i] is Player && localplayer.Operate != Character.OperateType.Magic)
             continue;
         if (characters[i].Picture.State != RenderChunk.RenderChunkState.Show)
             continue;
         Rectangle rect = new Rectangle((int)(characters[i].Position.X - characters[i].Picture.FrameSize.X * 0.3f),
                                         (int)(characters[i].Position.Y - characters[i].Picture.FrameSize.Y * 0.3f),
                                         (int)(characters[i].Picture.FrameSize.X * 0.6f),
                                         (int)(characters[i].Picture.FrameSize.Y * 0.6f));
         if (rect.Contains(new Point(x, y)))
         {
             host = characters[i];
             break;
         }
     }
     if (host == null)
     {
         for (int i = 0; i < battlecharacters.Count; ++i)
         {
             Rectangle rect = new Rectangle((int)(battlecharacters[i].Position.X - battlecharacters[i].Picture.FrameSize.X * 0.3f),
                                             (int)(battlecharacters[i].Position.Y - battlecharacters[i].Picture.FrameSize.Y * 0.3f),
                                             (int)(battlecharacters[i].Picture.FrameSize.X * 0.6f),
                                             (int)(battlecharacters[i].Picture.FrameSize.Y * 0.6f));
             if (rect.Contains(new Point(x, y)))
             {
                 host = battlecharacters[i];
                 break;
             }
         }
     }
     if (host != null)
     {
         if (_hostCharacter != null)
             _hostCharacter.Picture.HighLight = false;
         host.Picture.HighLight = true;
         _hostCharacter = host;
     #if WINDOWS
         if (host is Player)
         {
             if (localplayer.Operate == Character.OperateType.Magic)
             {
                 GameCursor.SetCursor(GameCursor.CursorType.Magic);
             }
         }
         else if (host is Npc)
         {
             GameCursor.SetCursor(GameCursor.CursorType.Talk);
         }
         else if (host is Monster)
         {
             if (localplayer.Operate == Character.OperateType.Attack || localplayer.Operate == Character.OperateType.None)
             {
                 GameCursor.SetCursor(GameCursor.CursorType.Attack);
             }
             else if (localplayer.Operate == Character.OperateType.Magic)
             {
                 GameCursor.SetCursor(GameCursor.CursorType.Magic);
             }
         }
     #endif
     }
     else
     {
     #if WINDOWS
         GameCursor.SetCursor(GameCursor.CursorType.Normal);
     #endif
         if (_hostCharacter != null)
         {
             _hostCharacter.Picture.HighLight = false;
             _hostCharacter = null;
         }
     }
 }
Beispiel #4
0
 public void ConfirmOperateTarget()
 {
     if (_hostCharacter != null && _roundtime > 0)
     {
         //若直接选中monster,为直接攻击
         if (localplayer.Operate == Character.OperateType.None)
             localplayer.Operate = Character.OperateType.Attack;
         localplayer.OperateTarget = _hostCharacter;
         _hostCharacter.Picture.HighLight = false;
         _hostCharacter = null;
         localplayer.CloseBattleMenu();
     }
 }
Beispiel #5
0
 public void AddMonster(Character ch)
 {
     battlecharacters.Add(ch);
 }
Beispiel #6
0
 public void AddCharacter(Character ch)
 {
     characters.Add(ch);
 }
Beispiel #7
0
 public ActionOrder(Character c, int s)
 {
     character = c;
     speed = s;
 }
Beispiel #8
0
        /// <summary>
        /// 角色被攻击后的Callback
        /// </summary>
        /// <param name="offense">进攻者</param>
        public void BeAttack(Character offense)
        {
            try
            {
                float dhp = MathHelper.Max(offense.ATK * 1.5f - def * 1.3f, 0);
                hp -= (int)dhp;
                //play number animation
                effects.NumberAnimation na = new effects.NumberAnimation((int)dhp);
                na.Position = new Vector2(this.Position.X, this.Position.Y - this.Picture.FrameSize.Y * 0.5f);
                na.Color = new Color(1.0f, 0.0f, 0.0f);
                na.Play(Scene);

                ClearActionSet();
                AddActionSet("BeAttack", CharacterState.BeAttack, CharacterActionSetChangeFactor.AnimationCompleted, null);
                if (hp <= 0)
                {
                    //ClearActionSet();
                    //AddActionSet("Dying", CharacterState.Dying, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    AddActionSet("Dead", CharacterState.Dead, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    offense.Notify(GameAction.Kill, this.templateid, 1);
                }
                else
                    AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.Immediate, null);
            }
            catch (NullReferenceException)
            {
                Log.WriteLine(ToString() + ":must had offense");
            }
        }
Beispiel #9
0
        protected void OnPicAnimationEvent(object sender, EventArgs e)
        {
            CharacterAnimation anim = sender as CharacterAnimation;
            if (anim.Name.Contains("Attack"))
            {
                if (attacktarget != null)
                {
                    attacktarget.BeAttack(this);
                    attacktarget = null;
                }
            }

        }