Example #1
0
        public override void CreateModel()
        {
            //AvatarModelData data = AvatarModelData.dataMap[1013];
            Debug.Log("TeleportPointSrcGearAgent create:" + ID);
            SubAssetCacheMgr.GetCharacterInstance("TeleportPointSrcGearAgent.prefab",
                                                  (prefab, guid, gameObject) =>
            {
                Transform = (gameObject as GameObject).transform;
                Vector3 point;
                if (MogoUtils.GetPointInTerrain(position.x, position.z, out point))
                {
                    Transform.position = point;
                }
                //Transform.position = position;
                Transform.eulerAngles = rotation;
                Transform.localScale  = scale;
                Transform.tag         = "Gear";

                TeleportPointSrcGear gear = Transform.GetComponent <TeleportPointSrcGear>();
                if (gear != null)
                {
                    gear.ID = ID;
                    Debug.Log("EntityTeleportSrc Gear ID: " + gear.ID);
                }
            }
                                                  );
        }
    protected void CreateMeteoriteBomb(Transform theTarget)
    {
        SubAssetCacheMgr.GetGearInstance("Meteolite.prefab", (prefabName, id, obj) =>
        {
            GameObject go = obj as GameObject;

            if (go == null)
            {
                return;
            }

            go.transform.position = transform.position;

            var script = go.AddComponent <MeteoriteBomb>();

            script.speed         = bombSpeed;
            script.rotationSpeed = bombRotationSpeed;

            script.shakeCamAnimID   = bombShakeCamAnimID;
            script.shakeCamAnimTime = bombShakeCamAnimTime;

            script.deleteTime = bombDeleteTime;
            script.target     = theTarget;

            script.canAttackDummy = bombCanAttackDummy;

            script.radius     = bombRadius;
            script.percentage = bombPercentage;
            script.damageMin  = bombDamageMin;
            script.damageMax  = bombDamageMax;

            CheckAllShootEnd();
        });
    }
Example #3
0
    protected void CreateNewMagma()
    {
        if (triggleEnable)
        {
            SubAssetCacheMgr.GetGearInstance("fx_scene_magma_98.prefab", (newName, newID, newMagma) =>
            {
                var magmaGo = newMagma as GameObject;
                if (magmaGo == null)
                {
                    return;
                }

                magmaGo.layer = 17;

                var magma = magmaGo.AddComponent <Magma>();

                magma.createMagmaTime     = createMagmaTime;
                magma.radius              = radius;
                magma.creationProbability = (int)(creationProbability);
                magma.remainTime          = nextMagmaRemainTime;
                magma.nextMagmaRemainTime = RandomHelper.GetRandomInt((int)(0.5 * nextMagmaRemainTime), (int)(1.5 * nextMagmaRemainTime));

                var boxCollider       = magmaGo.AddComponent <BoxCollider>();
                boxCollider.isTrigger = true;
                boxCollider.size      = new Vector3(2, 2, 2);

                if (gear != null)
                {
                    var magmaGear      = magmaGo.AddComponent <MagmaGear>();
                    magmaGear.burnTime = gear.burnTime;

                    magmaGear.magmaCanAttackDummy = gear.magmaCanAttackDummy;

                    magmaGear.magmaDamagePercentage = gear.magmaDamagePercentage;
                    magmaGear.magmaDamageMin        = gear.magmaDamageMin;
                    magmaGear.magmaDamageMax        = gear.magmaDamageMax;
                    magmaGear.magmaDamageInterval   = gear.magmaDamageInterval;

                    magmaGear.onFireCanAttackDummy = gear.onFireCanAttackDummy;

                    magmaGear.onFireDamagePercentage = gear.onFireDamagePercentage;
                    magmaGear.onFireDamageMin        = gear.onFireDamageMin;
                    magmaGear.onFireDamageMax        = gear.onFireDamageMax;
                    magmaGear.onFireDamageInterval   = gear.onFireDamageInterval;

                    var container             = magmaGo.AddComponent <MagmaInvisibleContainer>();
                    container.magmaGear       = magmaGear;
                    container.skillActionList = new int[1] {
                        20112
                    };
                }

                magmaGo.transform.position = RandomHelper.GetRandomVector3InRangeCircle(radius) + transform.position;

                createMagmaTimer = TimerHeap.AddTimer(0, 0, TryCreateNewMagma);
            });
        }
    }
Example #4
0
        /// <summary>
        /// 释放场景资源。
        /// </summary>
        public void UnloadScene(Action callBack)
        {
            if (m_currentMap != null)
            {
                try
                {
                    BillboardViewManager.Instance.Clear();
                    MogoFXManager.Instance.RemoveAllShadow();
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
                foreach (var item in m_sceneObjects)
                {
                    //AssetCacheMgr.UnloadAsset(item);
                    AssetCacheMgr.ReleaseInstance(item);
                }
                m_sceneObjects.Clear();
                AssetCacheMgr.ReleaseResource(m_lightmap);
                m_lightmap = null;
                AssetCacheMgr.ReleaseResource(m_lightProbes);
                m_lightProbes = null;
                StoryManager.Instance.ClearPreload();
                SubAssetCacheMgr.ReleaseCharacterResources();
                SubAssetCacheMgr.ReleaseGearResources();
                SfxHandler.UnloadAllFXs();
                if (!String.IsNullOrEmpty(m_lastSceneResourceName))
                {
                    AssetCacheMgr.ReleaseResource(m_lastSceneResourceName);
                }
                //ResourceManager.UnloadUnusedAssets();
                //GC.Collect();
                if (callBack != null)
                {
                    callBack();
                }

                //Debug.LogError("StartCoroutine UnloadUnusedAssets");
                //Driver.Instance.StartCoroutine(UnloadUnusedAssets(() =>
                //{
                //    //Debug.LogError("UnloadUnusedAssets finish");
                //    GC.Collect();
                //    if (callBack != null)
                //        callBack();
                //}));
            }
            else
            {
                if (callBack != null)
                {
                    callBack();
                }
            }
        }
Example #5
0
    void OnTriggerEnter()
    {
        if (m_entered)
        {
            m_entered = false;
            ClientEventData.TriggerGearEvent(20002);

            MainUIViewManager.Instance.ShowBossTarget(false);
            TimerHeap.AddTimer(1000, 0, () => { SubAssetCacheMgr.ReleaseCharacterResources(); EventDispatcher.TriggerEvent(Events.TowerEvent.EnterMap); });
        }
    }
Example #6
0
    private void DropRock(GameObject go)
    {
        SubAssetCacheMgr.GetGearInstance("DropRock", (prefabName, dbid, prefabGo) =>
        {
            if (MogoWorld.thePlayer.sceneId != MogoWorld.globalSetting.homeScene)
            {
                var rock = (prefabGo as GameObject).AddComponent <DropRock>();

                rock.canAttackDummy = dropRockCanAttackDummy;

                rock.radius     = dropRockRadius;
                rock.percentage = dropRockPercentage;
                rock.damageMin  = dropRockDamageMin;
                rock.damageMax  = dropRockDamageMax;

                rock.transform.position = RandomHelper.GetRandomVector3InRangeCircle(dropRockRadius, 10) + go.transform.position;
            }
        });
    }
Example #7
0
        public void LoadMonster(int mapID, Action callback, Action <int> process = null)
        {
            var models = new List <int>();

            foreach (var item in MogoUtils.GetSpaceLevelID(mapID))
            {
                models.AddRange(MogoUtils.GetSpawnPointMonsterID(item));
            }
            //if (process != null)
            //    process(80);
            if (models.Count > 0)
            {
                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                var monstersList = models.Select(x => AvatarModelData.dataMap.Get(x).prefabName).Distinct();
                var ms           = monstersList.ToArray();
                //Debug.LogWarning("[Info] pre load resource" + ms.PackArray());
                SubAssetCacheMgr.GetCharacterResourcesAutoRelease(ms, (obj) =>
                {
                    sw.Stop();
                    //Debug.LogInfo("preload Monster time: " + sw.ElapsedMilliseconds);
                    //LoadFX(monstersList, callback, process);
                    if (callback != null)
                    {
                        callback();
                    }
                }, (progress) =>
                {
                    if (process != null)
                    {
                        process((int)(5 * progress + 90));
                    }
                });
            }
            else
            {
                if (callback != null)
                {
                    callback();
                }
            }
        }
Example #8
0
    protected void Fire(GameObject go)
    {
        if (state == ConnonState.connon)
        {
            float h = transform.position.y - go.transform.position.y;
            float s = Vector3.Distance(new Vector3(go.transform.position.x, transform.position.y, go.transform.position.z), transform.position);

            float vy = Mathf.Sqrt(gravity * Mathf.Pow(s, 2) / (4 * s + 8 * h));
            float vx = 2 * vy;

            Vector3 directionX = (new Vector3(go.transform.position.x, transform.position.y, go.transform.position.z) - transform.position).normalized;
            Vector3 directionY = Vector3.up;

            Fire();

            SubAssetCacheMgr.GetGearInstance("Bomb.prefab", (prefabName, dbid, prefabGo) =>
            {
                //GameObject bomb = (GameObject)Instantiate(Resources.Load("Gear/10401_BigGunBall"));

                Bomb temp    = (prefabGo as GameObject).AddComponent <Bomb>();
                temp.gravity = gravity;

                temp.vx = vx;
                temp.vy = vy;

                temp.directionX = directionX;
                temp.directionY = directionY;

                temp.canAttackDummy = bombCanAttackDummy;

                temp.radius     = bombRadius;
                temp.percentage = bombPercentage;
                temp.damageMin  = bombDamageMin;
                temp.damageMax  = bombDamageMax;

                (prefabGo as GameObject).transform.position = transform.position;
            });

            ResetConnon(go);
        }
    }
Example #9
0
    public void ShootMeteoriteBomb()
    {
        if (triggleEnable && MogoWorld.thePlayer.sceneId != MogoWorld.globalSetting.homeScene)
        {
            SubAssetCacheMgr.GetGearInstance("Meteolite.prefab", (prefabName, id, obj) =>
            {
                GameObject go = obj as GameObject;

                if (go == null)
                {
                    return;
                }

                go.transform.position = transform.position;

                var script = go.AddComponent <MeteoriteBomb>();

                script.speed         = bombSpeed;
                script.rotationSpeed = bombRotationSpeed;

                script.shakeCamAnimID   = bombShakeCamAnimID;
                script.shakeCamAnimTime = bombShakeCamAnimTime;

                script.deleteTime = bombDeleteTime;
                script.target     = MogoWorld.thePlayer.Transform;

                script.canAttackDummy = bombCanAttackDummy;

                script.radius     = bombRadius;
                script.percentage = bombPercentage;
                script.damageMin  = bombDamageMin;
                script.damageMax  = bombDamageMax;

                timer = TimerHeap.AddTimer((uint)defaultShootTime, 0, ShootMeteoriteBomb);
            });
        }
    }
Example #10
0
        public override void CreateActualModel()
        {
            AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(m_monsterData.model, null);

            if (data == null)
            {
                LoggerHelper.Error("Model not found: " + m_monsterData.model);
                return;
            }
            LoggerHelper.Debug("monster create:" + ID + ",name:" + data.prefabName);
            SubAssetCacheMgr.GetCharacterInstance(data.prefabName,
                                                  (prefab, guid, gameObject) =>
            {
                if (this.Actor)
                {
                    this.Actor.Release();
                }

                if (Transform)
                {
                    AssetCacheMgr.ReleaseLocalInstance(Transform.gameObject);
                }

                GameObject           = (gameObject as GameObject);
                Transform            = GameObject.transform;
                Transform.localScale = scale;
                if (data.scale > 0)
                {
                    Transform.localScale = new Vector3(data.scale, data.scale, data.scale);
                }

                Transform.tag = "Monster";
                Transform.gameObject.layer = 11;
                sfxHandler = GameObject.AddComponent <SfxHandler>();
                motor      = GameObject.AddComponent <MogoMotorServer>();

                audioSource             = GameObject.AddComponent <AudioSource>();
                audioSource.rolloffMode = AudioRolloffMode.Custom;

                CharacterController controller = GameObject.GetComponent <CharacterController>();
                controller.radius = m_monsterData.scaleRadius / 100f;
                controller.height = EntityColiderHeight;
                float centerY     = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius);
                controller.center = new Vector3(0, centerY, 0);

                animator          = GameObject.GetComponent <Animator>();
                ActorMercenary ap = GameObject.AddComponent <ActorMercenary>();
                ap.theEntity      = this;
                this.Actor        = ap;
                UpdatePosition();
                if (data.originalRotation != null && data.originalRotation.Count == 3)
                {
                    Transform.eulerAngles = new Vector3(data.originalRotation[0], data.originalRotation[1], data.originalRotation[2]);
                }
                else
                {
                    Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position;
                    Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z));
                }
                motor.canTurn = !NotTurn();
                base.CreateModel();
                motor.SetAngularSpeed(400f);
                motor.acceleration = 2f;

                if (!NotTurn())
                {
                    Vector3 bornTargetToLookAt = MogoWorld.thePlayer.position;
                    Transform.LookAt(new Vector3(bornTargetToLookAt.x, Transform.position.y, bornTargetToLookAt.z));
                }


                #region Shader
                if (ShaderData.dataMap.ContainsKey(m_monsterData.shader) &&
                    GameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true) != null &&
                    ID != MogoWorld.theLittleGuyID)
                {
                    MogoFXManager.Instance.SetObjShader(GameObject, ShaderData.dataMap[m_monsterData.shader].name, ShaderData.dataMap[m_monsterData.shader].color);
                    MogoFXManager.Instance.AlphaFadeIn(GameObject, fadeInTime);
                }
                #endregion
                try
                {
                    if (m_monsterData != null && m_monsterData.bornFx != null)
                    {
                        foreach (var item in m_monsterData.bornFx)
                        {
                            sfxHandler.HandleFx(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Except(ex);
                }


                //开始执行出生流程
                m_bModelBuilded = true;

                m_aiRoot      = AIContainer.container.Get((uint)m_monsterData.aiId);
                uint waitTime = (uint)m_monsterData.bornTime;
                if (waitTime <= 1)    //容错
                {
                    waitTime = 3000;
                }
                if (blackBoard.timeoutId > 0)
                {
                    TimerHeap.DelTimer(blackBoard.timeoutId);
                }

                m_currentSee = m_monsterData.see;
                blackBoard.ChangeState(Mogo.AI.AIState.THINK_STATE);
                TimerHeap.AddTimer(waitTime, 0, RebornAnimationDelay);
                TimerHeap.AddTimer(waitTime, 0, BornedHandler);
                Actor.ActChangeHandle = ActionChange;
            }
                                                  );
        }
Example #11
0
        /*
         *      private void AttachBuildingModel()
         *      {
         *          GearParent[] gears = (GearParent[])GameObject.FindObjectsOfType(typeof(GearParent));
         *          foreach (GearParent gear in gears)
         *          {
         *              if (gear.ID == (uint)clientTrapId)
         *              {
         *                  Transform = gear.transform;
         *                  GameObject = gear.gameObject;
         *                  Transform.tag = "Monster";
         *                  // motor = GameObject.AddComponent<MogoMotorServer>();
         *                  animator = GameObject.GetComponent<Animator>();
         *
         *                  ActorDummy ap = GameObject.GetComponent<ActorDummy>();
         *                  if (ap == null)
         *                      ap = GameObject.AddComponent<ActorDummy>();
         *
         *                  ap.theEntity = this;
         *                  this.Actor = ap;
         *              }
         *          }
         *      }
         */
        public void CreatePlayerActualModel()
        {
            isCreatingModel = true;
            AssetCacheMgr.ReleaseLocalInstance(GameObject);
            AvatarModelData data = AvatarModelData.dataMap.Get((int)vocation);

            SubAssetCacheMgr.GetPlayerInstance(data.prefabName,
                                               (prefab, guid, go) =>
            {
                var gameObject = go as GameObject;
                var actor      = gameObject.AddComponent <ActorMercenary>();
                actor.InitEquipment((int)vocation);
                motor = gameObject.AddComponent <MogoMotorServer>();

                CharacterController controller = gameObject.GetComponent <CharacterController>();
                controller.radius = m_monsterData.scaleRadius / 100f;
                controller.height = EntityColiderHeight;
                float centerY     = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius);
                controller.center = new Vector3(0, centerY, 0);

                animator = gameObject.GetComponent <Animator>();

                sfxHandler = gameObject.AddComponent <SfxHandler>();

                actor.theEntity = this;

                GameObject = gameObject;
                Transform  = gameObject.transform;
                this.Actor = actor;
                //Transform.localScale = scale;
                Transform.tag = "OtherPlayer";
                Transform.gameObject.layer = 18;
                Vector3 targetToLookAt     = MogoWorld.thePlayer.Transform.position;
                Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z));

                UpdatePosition();

                base.CreateModel();
                LoadEquip();
                //gameObject.SetActive(false);
                gameObject.SetActive(true);
                isCreatingModel = false;
                if (m_factionFlag == 0)
                {
                    BillboardLogicManager.Instance.AddInfoBillboard(ID, Transform, this, true);
                }
                else
                {
                    BillboardLogicManager.Instance.AddInfoBillboard(ID, Transform, this, false);
                }

                MogoFXManager.Instance.AddShadow(Transform.gameObject, ID);

                #region 血条

                if (isLittleGuy)
                {
                    MainUILogicManager.Instance.SetMercenaryMessageInit(this);
                }
                else if (IsPVP())
                {
                    //logic
                }
                else
                {
                    hp = (uint)m_monsterData.hpBase;
                    //curHp = (uint)m_monsterData.hpBase;
                    if (m_monsterData != null && m_monsterData.hpShow != null && m_monsterData.hpShow.Count >= 3)
                    {
                        MainUILogicManager.Instance.SetBossMessageInit(this, m_monsterData.hpShow[2]);
                    }
                }

                #endregion


                //开始执行出生流程
                m_bModelBuilded = true;

                m_aiRoot = AIContainer.container.Get((uint)m_monsterData.aiId);

                uint waitTime = (uint)m_monsterData.bornTime;
                if (waitTime <= 1)    //容错
                {
                    waitTime = 3000;
                }
                if (blackBoard.timeoutId > 0)
                {
                    TimerHeap.DelTimer(blackBoard.timeoutId);
                }
                //LoggerHelper.Error("RebornAnimationDelay begin:" + waitTime);

                m_currentSee = m_monsterData.see;
                blackBoard.ChangeState(Mogo.AI.AIState.THINK_STATE);
                TimerHeap.AddTimer(waitTime, 0, RebornAnimationDelay);
                Actor.ActChangeHandle = ActionChange;
            }

                                               );
        }
Example #12
0
        public override void CreateModel()
        {
            if (belongAvatar != MogoWorld.thePlayer.ID)//不是自己的东西不显示,目前Entity会被创建,统一在退出副本时销毁掉落实体
            {
                Debug.Log("belongAvatar: " + belongAvatar + " " + MogoWorld.thePlayer.ID);
                return;
            }
            string modelName = null;

            if (gold != 0)//金币数量不为零,则这是金币
            {
                modelName = m_goldModelName;
            }
            else
            {//否则为装备
                int look    = -1;
                int quality = -1;
                if (ItemEquipmentData.dataMap.ContainsKey(itemId))
                {
                    look    = ItemEquipmentData.dataMap[itemId].look;
                    quality = ItemEquipmentData.dataMap[itemId].quality;
                }
                else if (ItemJewelData.dataMap.ContainsKey(itemId))
                {
                    look    = ItemJewelData.dataMap[itemId].look;
                    quality = ItemJewelData.dataMap[itemId].quality;
                }
                else if (ItemMaterialData.dataMap.ContainsKey(itemId))
                {
                    look    = ItemMaterialData.dataMap[itemId].look;
                    quality = ItemMaterialData.dataMap[itemId].quality;
                }
                if (look != -1)
                {
                    //var model = DropModelData.dataMap.FirstOrDefault(t => t.Value.type == equipment.type && t.Value.subtype == equipment.subtype);
                    var model = DropModelData.dataMap.Get(look);
                    if (model != null)
                    {
                        modelName = model.prefab;
                    }

                    var fx = DropFXData.dataMap.FirstOrDefault(t => t.Value.quality == quality);
                    if (fx.Value != null)
                    {
                        m_glowFxId = fx.Value.fx;
                    }
                }
            }
            //Debug.Log("EntityDrop create:" + ID);
            Action <UnityEngine.Object> action = (gameObject) =>
            {
                GameObject         = gameObject as GameObject;
                Transform          = GameObject.transform;
                Transform.position = position;
                //Transform.eulerAngles = rotation;
                Transform.localScale = scale;
                Transform.tag        = "Item";
                UpdatePosition();

                sfxHandler = GameObject.AddComponent <SfxHandler>();
                BoxCollider collider = GameObject.AddComponent <BoxCollider>();
                collider.isTrigger = true;
                collider.size      = new Vector3(2, 2, 4);
                var ap = GameObject.AddComponent <ActorDrop>();
                ap.theEntity = this;
                Actor        = ap;
                if (m_glowFxId > 0)
                {
                    sfxHandler.HandleFx(m_glowFxId);
                }
                //ap.TweenTo(position, tweenTarget, 0.5f);

                Transform.position = new Vector3(tweenTarget.x, tweenTarget.y, tweenTarget.z);
                Vector3 tempVec = Transform.position;
                Mogo.Util.MogoUtils.GetPointInTerrain(tempVec.x, tempVec.z, out tempVec);
                Transform.position = new Vector3(tempVec.x, tempVec.y + 0.5f, tempVec.z);
                //    transform.position = tweenEnd + new Vector3(0, 0.5f, 0);

                ap.ThrowTo(Transform.position.y + 3f, 0.25f);
                tId = TimerHeap.AddTimer(1500, 0, DragToPlayer);
            };

            if (String.IsNullOrEmpty(modelName))
            {
                noModel = true;
                var go = new GameObject();
                action(go);
            }
            else
            {
                SubAssetCacheMgr.GetCharacterInstance(modelName,
                                                      (prefab, guid, gameObject) =>
                {
                    action(gameObject);
                }
                                                      );
            }
        }
Example #13
0
        public override void CreateActualModel()
        {
            isCreatingModel = true;
            AssetCacheMgr.ReleaseLocalInstance(GameObject);
            AvatarModelData data = AvatarModelData.dataMap.Get((int)vocation);

            SubAssetCacheMgr.GetPlayerInstance(data.prefabName,
                                               (prefab, guid, go) =>
            {
                var gameObject = go as GameObject;
                var actor      = gameObject.AddComponent <ActorPlayer>();

                actor.theEntity = this;
                motor           = gameObject.AddComponent <MogoMotorServer>();
                animator        = gameObject.GetComponent <Animator>();

                sfxHandler = gameObject.AddComponent <SfxHandler>();

                //actor.mogoMotor = motor;

                audioSource             = gameObject.AddComponent <AudioSource>();
                audioSource.rolloffMode = AudioRolloffMode.Custom;

                GameObject       = gameObject;
                Transform        = gameObject.transform;
                GameObject.layer = 20;    //otherplayer
                //Debug.LogError("entityPlayer.CreateActualModel:" + gameObject.layer);
                // Debug.LogError(GameObject.name + " " + ID + " Player CreateActualModel: " + Transform.position);

                this.Actor = actor;
                //Transform.localScale = scale;
                Transform.tag = "OtherPlayer";

                UpdatePosition();
                foreach (var item in gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true))
                {
                    item.enabled = false;
                }

                if (data.scale > 0)
                {
                    Transform.localScale = new Vector3(data.scale, data.scale, data.scale);
                }

                base.CreateModel();

                LoadEquip();

                foreach (var item in gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true))
                {
                    item.enabled = true;
                }
                //Debug.Log("AddComponent<CombineSkinnedMeshes>");

                //gameObject.AddComponent<CombineSkinnedMeshes>();
                //Debug.Log("AddComponent<CombineSkinnedMeshes>");
                gameObject.SetActive(false);
                idleTimer = TimerHeap.AddTimer(1000, 0, DelayCheckIdle);
                TimerHeap.AddTimer(3000, 0, () =>
                {
                    if (gameObject == null)
                    {
                        return;
                    }
                    gameObject.SetActive(true);
                    isCreatingModel = false;

                    SetBillBoard();

                    MogoFXManager.Instance.AddShadow(gameObject, ID);

                    //gameObject.AddComponent<MogoObjOpt>().ObjType = MogoObjType.Player;

                    //if (gameObject.GetComponent<Animator>() != null)
                    //{
                    //    gameObject.GetComponent<Animator>().enabled = false;
                    //}

                    //if (gameObject.GetComponent<Animation>() != null)
                    //{
                    //    gameObject.GetComponent<Animation>().enabled = false;
                    //}
                });
                Actor.ActChangeHandle = ActionChange;

                UpdateDressWing();
                AddEquipFX(loadedEquipId);
                AddJewelFX(loadedJewelId);
                AddStrenthFX(loadedStrengthenId);
            }

                                               );
        }
Example #14
0
        public override void CreateActualModel()
        {
            AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(model, null);

            if (data == null)
            {
                Debug.LogError("Model not found: " + model);
                return;
            }
            SubAssetCacheMgr.GetCharacterInstance(data.prefabName,
                                                  (prefab, guid, gameObject) =>
            {
                if (this.Actor)
                {
                    this.Actor.Release();
                }
                if (Transform)
                {
                    AssetCacheMgr.ReleaseLocalInstance(Transform.gameObject);
                }
                GameObject = (gameObject as GameObject);

                Transform                  = GameObject.transform;
                Transform.localScale       = scale;
                Transform.tag              = "Monster";
                Transform.gameObject.layer = 11;    //monster

                sfxHandler = GameObject.AddComponent <SfxHandler>();
                motor      = GameObject.AddComponent <MogoMotorServer>();

                audioSource             = GameObject.AddComponent <AudioSource>();
                audioSource.rolloffMode = AudioRolloffMode.Custom;

                if (m_monsterData.notTurn == 0)
                {
                    motor.SetAngularSpeed(360f);
                }
                else
                {
                    motor.canMove = false;
                    motor.canTurn = false;
                }
                Debug.Log(" m_monsterData.scaleRadius:" + m_monsterData.scaleRadius);
                CharacterController controller = GameObject.GetComponent <CharacterController>();
                controller.radius = m_monsterData.scaleRadius / 100f;
                controller.height = EntityColiderHeight;
                float centerY     = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius);
                controller.center = new Vector3(0, centerY, 0);
                animator          = GameObject.GetComponent <Animator>();
                //animator.speed = 0.3f;
                ActorMonster ap = GameObject.AddComponent <ActorMonster>();
                ap.theEntity    = this;
                this.Actor      = ap;
                UpdatePosition();
                if (data.originalRotation != null && data.originalRotation.Count == 3)
                {
                    Transform.eulerAngles = new Vector3(data.originalRotation[0], data.originalRotation[1], data.originalRotation[2]);
                }
                else
                {
                    Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position;
                    Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z));
                }
                base.CreateModel();
                animator.applyRootMotion = false;

                #region Shader
                if (ShaderData.dataMap.ContainsKey(m_monsterData.shader) &&
                    (GameObject.GetComponentsInChildren <SkinnedMeshRenderer>(true) != null || GameObject.GetComponentsInChildren <MeshRenderer>(true) != null))
                {
                    MogoFXManager.Instance.SetObjShader(GameObject, ShaderData.dataMap[m_monsterData.shader].name, ShaderData.dataMap[m_monsterData.shader].color);
                    MogoFXManager.Instance.AlphaFadeIn(GameObject, 0.3f);
                }
                #endregion

                if (data.scale > 0)
                {
                    Transform.localScale = new Vector3(data.scale, data.scale, data.scale);
                }
                try
                {
                    if (m_monsterData != null && m_monsterData.bornFx != null && PlayBornFX)
                    {
                        foreach (var item in m_monsterData.bornFx)
                        {
                            sfxHandler.HandleFx(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
                uint waitTime = (uint)m_monsterData.bornTime;
                if (waitTime <= 1)    //容错
                {
                    waitTime = 3000;
                }
                BornedHandler();
                Actor.ActChangeHandle = ActionChange;
            }
                                                  );
        }