Esempio n. 1
0
        /// <summary>
        /// 根據提升的人口數改變主城外觀
        /// </summary>
        private void upgradeSelfCastle()
        {
            SceneObj sceneObj;

            if (GameCore.NetData.TryGetSceneObjData(GameCore.NetData.SelfCastle.Guid, out sceneObj) == false)
            {
                return;
            }

            CastleObj castle = sceneObj as CastleObj;

            var  newPrefab        = BuildingData.GetCastle(castle.Culture(), castle.Population()).prefab;
            int  scaffoldSerialID = 0;
            bool haveOldCastle    = false;

            if (GameCore.Entity.HasEntity(GameCore.NetData.SelfCastle.Guid))
            {
                var castleEntity = GameCore.Entity.GetEntity(GameCore.NetData.SelfCastle.Guid);

                // 人口提升後仍使用相同主堡外觀
                if (System.IO.Path.GetFileNameWithoutExtension(castleEntity.EntityAssetName).Equals(newPrefab))
                {
                    return;
                }

                haveOldCastle = true;

                // 顯示鷹架
                scaffoldSerialID = GameCore.Entity.GenerateSerialId();
                GameCore.Entity.ShowMisc(new MiscEntityData(scaffoldSerialID, Constant.Resource.Scaffold)
                {
                    Position = castle.Position()
                });
            }

            MEC.Timing.CallDelayed(Constant.Resource.ConstructTime, () =>
            {
                // 隱藏舊主堡
                if (haveOldCastle)
                {
                    GameCore.Entity.HideEntity(GameCore.NetData.SelfCastle.Guid);
                }

                // 移除鷹架
                GameCore.Entity.HideEntity(scaffoldSerialID);

                // 顯示新主堡
                CastleEntityData data = new CastleEntityData(GameCore.NetData.SelfCastle.Guid, newPrefab)
                {
                    Position = castle.Position()
                };
                GameCore.Entity.ShowCastle(data);

                // 播放建設完成特效
                int fxSerialID = GameCore.Entity.GenerateSerialId();
                GameCore.Entity.ShowParticle(new ParticleEntityData(fxSerialID, Constant.Resource.ConstructFX, 0)
                {
                    Position = castle.Position()
                });
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 根據GUID產生對應的主堡外觀
        /// </summary>
        /// <param name="guid"></param>
        private void createCastleEntity(int guid)
        {
            SceneObj sceneObj;

            if (GameCore.NetData.TryGetSceneObjData(guid, out sceneObj) == false)
            {
                return;
            }

            if (GameCore.Entity.HasEntity(guid))
            {
                return;
            }

            CastleObj        castle = sceneObj as CastleObj;
            CastleEntityData data   = new CastleEntityData(castle.Guid(), BuildingData.GetCastle(castle.Culture(), castle.Population()).prefab)
            {
                Position = castle.Position()
            };

            GameCore.Entity.ShowCastle(data);
        }