Exemplo n.º 1
0
    public void AddFastShadow(GameObject model, RoleManager.EntityType type)
    {
        if (type == RoleManager.EntityType.EntityType_Lingqi)
        {
            return;
        }
        if (model == null)
        {
            return;
        }
        Transform transform = model.transform.FindChild("EF01");

        if (transform != null && transform.FindChild("shadow") == null)
        {
            GameObject gameObject = new GameObject("shadow");
            gameObject.transform.SetParent(transform);
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.localPosition = new Vector3(0f, 0.2f, 0f);
            gameObject.layer = transform.gameObject.layer;
            FS_ShadowSimple fS_ShadowSimple = gameObject.AddComponent <FS_ShadowSimple>();
            fS_ShadowSimple.shadowMaterial    = Resources.Load <Material>("Other/ShadowMaterial");
            fS_ShadowSimple.layerMask         = ~LayerMask.NameToLayer("Ground");
            fS_ShadowSimple.shadowHoverHeight = 0f;
            fS_ShadowSimple.girth             = ((!(model.transform.parent.localScale != Vector3.one)) ? 0.4f : 1f);
        }
    }
Exemplo n.º 2
0
    private string EntityTypeToString(RoleManager.EntityType type)
    {
        switch (type)
        {
        case RoleManager.EntityType.EntityType_Self:
            return("Self");

        case RoleManager.EntityType.EntityType_Role:
            return("Player");

        case RoleManager.EntityType.EntityType_Npc:
        case RoleManager.EntityType.EntityType_Lingqi:
        case RoleManager.EntityType.EntityType_Partner:
        case RoleManager.EntityType.EntityType_Aider:
        case RoleManager.EntityType.EntityType_Pet:
        case RoleManager.EntityType.EntityType_Beauty:
        case RoleManager.EntityType.EntityType_XunLuo:
            return("Npc");

        case RoleManager.EntityType.EntityType_Monster:
            return("Monster");

        default:
            return(string.Empty);
        }
    }
Exemplo n.º 3
0
    private static int IntToEnum(IntPtr L)
    {
        int num = (int)LuaDLL.lua_tonumber(L, 1);

        RoleManager.EntityType entityType = (RoleManager.EntityType)num;
        ToLua.Push(L, entityType);
        return(1);
    }
Exemplo n.º 4
0
    private GameObject _loadEntityRes(RoleManager.EntityType type, string id)
    {
        GameObject gameObject = null;

        switch (type)
        {
        case RoleManager.EntityType.EntityType_Self:
        {
            GameObject original = Util.LoadPrefab("Prefab/SceneObj/MainRole");
            gameObject = UnityEngine.Object.Instantiate <GameObject>(original);
            break;
        }

        case RoleManager.EntityType.EntityType_Role:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/Role", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Npc:
        case RoleManager.EntityType.EntityType_XunLuo:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/Npc", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Monster:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/Monster", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Lingqi:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/LingQi", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Partner:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/Partner", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Aider:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/LingQi", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Pet:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/Pet", 15, null);
            break;

        case RoleManager.EntityType.EntityType_Beauty:
            gameObject = ObjectPool.instance.PushToPool("Prefab/SceneObj/Beauty", 15, null);
            break;
        }
        gameObject.name = this.GetEntityName(type, id);
        return(gameObject);
    }
Exemplo n.º 5
0
    private void AsyncLoadCharacter(Transform parent, int shape, RoleManager.EntityType type, SceneEntity entity, Action <GameObject, string> callback)
    {
        object[] array = Util.CallMethod("PLAYERLOADER", "GetPlayerAndNpcResPath", new object[]
        {
            (int)type,
            entity.sex,
            shape
        });
        if (array == null || array.Length == 0)
        {
            Debug.LogError("获取角色npc模型资源路径错误");
            return;
        }
        string prefabPath = (string)array[0];

        ObjectPool.instance.AsyncPushToPool(prefabPath, (!entity.isBoss) ? 15 : 2, parent, 0f, 0f, 0f, callback);
    }
Exemplo n.º 6
0
    private static int AddFastShadow(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 3);
            EntityCreate           entityCreate = (EntityCreate)ToLua.CheckObject(L, 1, typeof(EntityCreate));
            GameObject             model        = (GameObject)ToLua.CheckUnityObject(L, 2, typeof(GameObject));
            RoleManager.EntityType type         = (RoleManager.EntityType)((int)ToLua.CheckObject(L, 3, typeof(RoleManager.EntityType)));
            entityCreate.AddFastShadow(model, type);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemplo n.º 7
0
 private void SetEntityBaseInfo(SceneEntity obj, GameObject model, string name, float speed, int grade, int comp, int maxhp, int hp, string ownerId, RoleManager.EntityType entityType, string pkMode)
 {
     if (entityType == RoleManager.EntityType.EntityType_Self)
     {
         this._mainRole = obj;
     }
     if (entityType == RoleManager.EntityType.EntityType_Self || (ownerId == Singleton <RoleManager> .Instance.mainRole.id && (entityType == RoleManager.EntityType.EntityType_Partner || entityType == RoleManager.EntityType.EntityType_Lingqi || entityType == RoleManager.EntityType.EntityType_Pet || entityType == RoleManager.EntityType.EntityType_Beauty)))
     {
         obj.ChangeShader(model);
     }
     if (speed > 0f && obj.move != null)
     {
         obj.move.speed = speed;
     }
     obj.model      = model;
     obj.grade      = grade;
     obj.ownerId    = ownerId;
     obj.comp       = comp;
     obj.maxhp      = maxhp;
     obj.hp         = hp;
     obj.entityType = entityType;
     obj.AddHeadTitle(name);
     obj.UpdateMood(pkMode);
     obj.tag = this.EntityTypeToString(entityType);
     obj.gameObject.layer = 8;
     if (model != null)
     {
         BoxCollider component = model.GetComponent <BoxCollider>();
         if (component != null)
         {
             BoxCollider orAddComponent = obj.transform.GetOrAddComponent <BoxCollider>();
             orAddComponent.center    = component.center;
             orAddComponent.size      = component.size;
             orAddComponent.isTrigger = true;
             component.enabled        = false;
         }
         this.SetEntityLayer(model.transform);
         model.tag = obj.tag;
         model.transform.GetOrAddComponent <AnimationEventReceiver>();
         this.AddFastShadow(model, entityType);
     }
 }
Exemplo n.º 8
0
    private void SetEntityInfo(GameObject go, GameObject model, Vector3 pos, int dir360, float speed, SceneEntity obj, string name, int grade, string ownerId, int comp, int maxhp, int hp, bool canAttack, RoleManager.EntityType entityType, string pkMode = "")
    {
        go.transform.position = pos;
        obj.ChangeDir(dir360);
        this.SetEntityBaseInfo(obj, model, name, speed, grade, comp, maxhp, hp, ownerId, entityType, pkMode);
        switch (entityType)
        {
        case RoleManager.EntityType.EntityType_Self:
            this.SetSelfInfo(obj, pos);
            break;

        case RoleManager.EntityType.EntityType_Role:
            if (obj.id.Length > 0)
            {
                this.SetPlayerInfo(obj);
            }
            break;

        case RoleManager.EntityType.EntityType_Npc:
            this.SetNpcInfo(obj);
            break;

        case RoleManager.EntityType.EntityType_Monster:
            this.SetMonsterInfo(obj);
            break;

        case RoleManager.EntityType.EntityType_Lingqi:
            this.SetLingQiInfo(obj);
            break;

        case RoleManager.EntityType.EntityType_Partner:
            this.SetPartnerInfo(obj);
            break;

        case RoleManager.EntityType.EntityType_Aider:
            this.AddRoleAction(obj);
            break;

        case RoleManager.EntityType.EntityType_Pet:
            this.SetPetInfo(obj);
            break;

        case RoleManager.EntityType.EntityType_Beauty:
            this.SetBeautyInfo(obj);
            break;

        case RoleManager.EntityType.EntityType_XunLuo:
            this.AddRoleAction(obj);
            break;
        }
        obj.hp = hp;
        obj.UpdateBlockSetting(false);
        if (entityType == RoleManager.EntityType.EntityType_Lingqi || entityType == RoleManager.EntityType.EntityType_Partner || entityType == RoleManager.EntityType.EntityType_Pet || entityType == RoleManager.EntityType.EntityType_Beauty)
        {
            RoleManager.partnerAndLingQiEntities[obj.id] = obj;
        }
        else if (entityType == RoleManager.EntityType.EntityType_XunLuo)
        {
            RoleManager.xunLuoEntities.Add(obj);
        }
        else
        {
            RoleManager.sceneEntities[obj.id] = obj;
        }
    }
Exemplo n.º 9
0
    private void AsyncInitilizeEntity(Aoi_add_normalmsg nmsg, S2c_aoi_syncplayer syncPlayer, S2c_aoi_syncnpc syncNpc, string name, string ownerId, RoleManager.EntityType entityType, Action <GameObject> callback = null)
    {
        GameObject  go  = this._loadEntityRes(entityType, nmsg.rid);
        SceneEntity obj = null;

        if (go)
        {
            obj = go.GetComponent <SceneEntity>();
            Util.CallMethod("PLAYERLOADER", "SetXlsInfo", new object[]
            {
                obj,
                (int)entityType,
                nmsg.char_no,
                (syncPlayer == null) ? 0 : syncPlayer.isyunbiao
            });
            if (syncPlayer != null)
            {
                obj.SetData(nmsg.rid, nmsg.char_no, syncPlayer.sex, syncPlayer.speed, syncPlayer.weapon, syncPlayer.mount_model, syncPlayer.partnerhorse_model, syncPlayer.lingqin_model, syncPlayer.lingyi_model, syncPlayer.pet_model, syncPlayer.shenjian_model, syncPlayer.shenyi_model, syncPlayer.jingmai_model, syncPlayer.score, syncPlayer.up_mount, syncPlayer.up_horse, syncPlayer.fashion, syncPlayer.dazuo, 0, 0, syncPlayer.isyunbiao);
                obj.SetKeyValue("clubname", syncPlayer.clubname);
                obj.SetKeyValue("clubpost", syncPlayer.clubpost);
            }
            else
            {
                obj.SetData(nmsg.rid, nmsg.char_no, 0, 0f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, syncNpc.shield_hp, syncNpc.shield_hpmax, 0);
            }
            int shape = (syncPlayer == null) ? syncNpc.shape : syncPlayer.shape;
            if (syncPlayer != null && syncPlayer.fashion > 0)
            {
                shape = syncPlayer.fashion;
            }
            int    grade     = (syncPlayer == null) ? syncNpc.grade : syncPlayer.grade;
            int    comp      = (syncPlayer == null) ? syncNpc.comp : syncPlayer.comp;
            bool   canAttack = syncPlayer != null || syncNpc.canattk == 1;
            string pkMode    = (syncPlayer == null) ? string.Empty : syncPlayer.pkinfo;
            this.AsyncLoadCharacter(go.transform, shape, entityType, obj, delegate(GameObject model, string prefabPath)
            {
                if (model == null)
                {
                    model        = Util.LoadBucket(go.transform);
                    obj.isBucket = true;
                }
                model.transform.localScale = Vector3.one;
                Vector3 pos = Util.Convert2RealPosition(nmsg.x, nmsg.y, nmsg.z);
                this.SetEntityInfo(go, model, pos, (syncPlayer == null) ? syncNpc.dir : syncPlayer.dir360, (syncPlayer == null) ? 0f : syncPlayer.speed, obj, name, grade, ownerId, comp, nmsg.hpmax, nmsg.hp, canAttack, entityType, pkMode);
                if (callback != null)
                {
                    callback(go);
                }
                if (syncPlayer != null)
                {
                    Util.CallMethod("PLAYERLOADER", "LoadOtherShape", new object[]
                    {
                        obj,
                        (int)entityType,
                        syncPlayer.shenjian_model,
                        syncPlayer.shenyi_model
                    });
                    if (obj.up_mount == 1)
                    {
                        obj.isRide = true;
                    }
                }
            });
            return;
        }
    }
Exemplo n.º 10
0
 private string GetEntityName(RoleManager.EntityType type, string id)
 {
     return(string.Format("{0}_{1}", this.EntityTypeToString(type), id));
 }