using CommonAI.Zone;
using CommonAI.Zone.ZoneEditor;
using CommonAIClient.Client;
using CommonLang;
using CommonLang.Protocol;
using GameEditorPlugin.Win32.BattleClient;
using GameEditorPlugin.Win32.Runtime;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace ZeusServerTestClient
{
    public class FormTestClient : FormAbstractClient
    {
        private NodeTestBattleClient mBattle;
        private float mClientSyncInRange;
        private float mClientSyncOutRange;


        public FormTestClient()
        {
        }

        //--------------------------------------------------------------------------------------------
        public override EditorTemplates DataRoot
        {
            get { return mBattle.DataRoot; }
        }
        public override AbstractBattle GenBattle()
        {
            return mBattle;
        }
        public override DisplayLayerWorld GenDisplay(PictureBox control)
        {
            return new DisplayLayerWorld();
        }
        protected override void OnLoaded()
        {
            this.BattlePanel.DisplayWorld.SpaceDIV = mNode.Zone.SpaceDIV;
            this.BattlePanel.DisplayWorld.ShowGrid = true;
            this.BattlePanel.DisplayWorld.ShowHP = true;
            this.BattlePanel.DisplayWorld.ShowLog = true;
            this.BattlePanel.DisplayWorld.ShowZ = true;
            this.BattlePanel.DisplayWorld.Layer.ActorSyncMode = CommonAI.ZoneClient.SyncMode.MoveByClient_PreSkillByClient;
            mBattle.Layer.ActorAdded += Layer_ActorAdded;
            mBattle.Layer.MessageReceived += Layer_MessageReceived;
            mBattle.Start();
        }

        protected override void OnClose()
        {
            mBattle.Stop();
        }

        //--------------------------------------------------------------------------------------------
        private void Layer_ActorAdded(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneActor actor)
        {
        }
        private void Layer_MessageReceived(CommonAI.ZoneClient.ZoneLayer layer, IMessage msg)
        {

        }
        protected override void DisplayActor_OnRender(Graphics g, DisplayGameUnit unit)
        {
            Pen pen = new Pen(Color.FromArgb(128, 255, 255, 255));
            pen.Width = 1f / BattlePanel.DisplayWorld.getCameraScale();
            g.DrawArc(pen,
                -mClientSyncInRange,
                -mClientSyncInRange,
                mClientSyncInRange * 2,
                mClientSyncInRange * 2,
                0, 360);
            g.DrawArc(pen,
                -mClientSyncOutRange,
                -mClientSyncOutRange,
                mClientSyncOutRange * 2,
                mClientSyncOutRange * 2,
                0, 360);
        }
    }
}