Пример #1
0
    /// <summary>
    /// 添加一个新的精灵
    /// </summary>
    /// <param name="type"></param>
    public static void AddNewEntity(SpriteType type, EntityServerInfo info = null)
    {
        if (info == null)
        {
            info = new EntityServerInfo();
        }
        EntityParent entity = null;

        switch (type)
        {
        case SpriteType.NONE:

            break;

        case SpriteType.Myself:
            if (thePlayer == null)
            {
                entity        = new EntityMyself();
                info.id       = 1000;
                info.dataId   = 1;
                info.position = Vector3.zero;
                info.x        = 100;
                info.y        = 100;
            }
            else
            {
                info.id       = 1000;
                info.position = Vector3.zero;
                info.x        = 100;
                info.y        = 100;
                thePlayer.SetEntityServerInfo(info);
                thePlayer.UpdatePosition();
                return;
            }

            break;

        case SpriteType.Player:
            entity = new EntityPlayer();
            break;

        case SpriteType.Monster:
            entity = new EntityMonster();
            break;

        default:
            break;
        }
        if (entity == null)
        {
            return;
        }
        entity.SetEntityServerInfo(info);
        entity.CreateModel();
        entity.EnterWorld();
        OnEnterWorld(entity);
    }
Пример #2
0
    protected override void OnLoadComplete(params object[] args)
    {
        Debuger.Log("CityState-->OnLoadComplete");

        GameWorld.AddNewEntity(SpriteType.Myself);
        GameObject[] arr = GameObject.FindGameObjectsWithTag("MonsterPoint");
        for (int i = 0; i < arr.Length; i++)
        {
            EntityServerInfo info = new EntityServerInfo();
            info.id       = (uint)(i + 1);
            info.dataId   = 2;
            info.position = arr[i].transform.position;
            info.x        = (short)info.position.x;
            info.y        = (short)info.position.z;
            arr[i].SetActive(false);
            GameWorld.AddNewEntity(SpriteType.Monster, info);
        }
        GUIManager.ShowView(PanelNameConst.EasyTouchControlsPanel);
        GUIManager.ShowView(PanelNameConst.FunctionButtonPanel);
    }
Пример #3
0
 public void SetEntityServerInfo(EntityServerInfo info)
 {
     serverInfo   = info;
     ID           = info.id;
     bornPosition = info.position;
 }