예제 #1
0
        public override void OnShow(object userData)
        {
            base.OnShow(userData);
            m_AircraftData = EntityData as AircraftData;
            if (m_AircraftData == null)
            {
                HotLog.Error("Aircraft data is invalid.");
                return;
            }

            RuntimeEntity.Name = Utility.Text.Format("Aircraft ({0})", RuntimeEntity.Id.ToString());
            GameEntry.Entity.ShowThruster(m_AircraftData.ThrusterData);     //显示推进器

            //显示所有武器
            List <WeaponData> weaponDatas = m_AircraftData.AllWeaponData;

            for (int i = 0; i < weaponDatas.Count; i++)
            {
                GameEntry.Entity.ShowWeapon(weaponDatas[i]);
            }

            //显示所有装甲
            List <ArmorData> armorDatas = m_AircraftData.AllArmorData;

            for (int i = 0; i < armorDatas.Count; i++)
            {
                GameEntry.Entity.ShowArmor(armorDatas[i]);
            }
        }
예제 #2
0
 public override void OnShow(object userData)
 {
     base.OnShow(userData);
     m_BulletData = EntityData as BulletData;
     if (m_BulletData == null)
     {
         HotLog.Error("Bullet data is invalid.");
         return;
     }
 }
예제 #3
0
 /// <summary>
 /// 实体显示
 /// </summary>
 /// <param name="userData">用户自定义数据</param>
 public override void OnShow(object userData)
 {
     base.OnShow(userData);
     m_TargetableObjectData = EntityData as TargetableObjectData;
     if (m_TargetableObjectData == null)
     {
         HotLog.Error("Targetable object data is invalid -> m_TargetableObjectData == null");
         return;
     }
 }
 /// <summary>
 /// 实体显示
 /// </summary>
 /// <param name="userData">用户自定义数据</param>
 public virtual void OnShow(object userData)
 {
     EntityData = userData as EntityData;
     if (EntityData == null)
     {
         HotLog.Error("Entity data is invalid -> m_EntityData == null");
         return;
     }
     RuntimeEntity.Position = EntityData.Position;
     RuntimeEntity.Rotation = EntityData.Rotation;
 }
        //加载场景失败的回调
        private void OnLoadSceneFailure(object sender, GameEventArgs e)
        {
            LoadSceneFailureEventArgs args = e as LoadSceneFailureEventArgs;

            if (args.UserData != this)
            {
                return;
            }

            HotLog.Error("Load scene '{0}' failure, error message '{1}'.", args.SceneAssetName, args.ErrorMessage);
        }
예제 #6
0
        public override void OnShow(object userData)
        {
            base.OnShow(userData);

            m_AsteroidData = EntityData as AsteroidData;
            if (m_AsteroidData == null)
            {
                HotLog.Error("Asteroid data is invalid.");
                return;
            }

            m_RotateSphere = Random.insideUnitSphere;
        }
예제 #7
0
        private float m_ElapseSeconds = 0f;     //记录时间

        public override void OnShow(object userData)
        {
            base.OnShow(userData);

            m_EffectData = userData as EffectData;
            if (m_EffectData == null)
            {
                HotLog.Error("Effect data is invalid.");
                return;
            }

            m_ElapseSeconds = 0f;
        }
예제 #8
0
        public override void OnShow(object userData)
        {
            base.OnShow(userData);

            m_WeaponData = userData as WeaponData;
            if (m_WeaponData == null)
            {
                HotLog.Error("Weapon data is invalid.");
                return;
            }

            //挂载到拥有者实体上
            GameEntry.Entity.AttachEntity(this, m_WeaponData.OwnerId, AttachPointName);
        }
예제 #9
0
        public override void OnShow(object userData)
        {
            base.OnShow(userData);
            //装甲数据
            m_ArmorData = userData as ArmorData;
            if (m_ArmorData == null)
            {
                HotLog.Error("Armor data is invalid.");
                return;
            }

            //绑定到拥有者实体上
            GameEntry.Entity.AttachEntity(this, m_ArmorData.OwnerId, AttachPointName);
        }
        private Canvas m_CachedCanvas = null;                               //画布

        //这种方法后期可以抽象出去,例如使用接口、使用特性获取调用等
        public HPBarComponent()
        {
            GameObject obj = new GameObject("HP Bar");

            obj.transform.SetParent(HotfixEntry.GlobalObj.transform.Find("Customs"));
            (obj.AddComponent(typeof(ComponentView)) as ComponentView).Component = this;

            GameObject InstaceObj = new GameObject("HP Bar Instance");

            InstaceObj.transform.SetParent(obj.transform);

            m_CachedCanvas            = InstaceObj.AddComponent(typeof(Canvas)) as Canvas;
            m_CachedCanvas.renderMode = RenderMode.ScreenSpaceOverlay;

            CanvasScaler scaler = InstaceObj.AddComponent(typeof(CanvasScaler)) as CanvasScaler;

            scaler.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            scaler.referenceResolution = new Vector2(1080, 1920);
            scaler.screenMatchMode     = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            scaler.matchWidthOrHeight  = 0;

            m_HPBarInstanceRoot = InstaceObj.transform;
            if (m_HPBarInstanceRoot == null)
            {
                HotLog.Error("You must set HP bar instance root first.");
                return;
            }

            m_HPBarItemObjectPool = HotfixEntry.ObjectPool.CreateSingleSpawnObjectPool <HPBarItemObject>("HPBarItem", m_InstancePoolCapacity);
            m_ListActiveHPBar     = new List <HPBarItem>();

            GameEntry.Resource.LoadAsset(HotAssetUtility.GetUIItemsAsset("HPBarItem"), RuntimeConstant.AssetPriority.UIFormAsset,
                                         (assetName, asset, duration, userData) =>
            {
                HotLog.Info("Load HPBarItem OK.");
                m_HPBarItemTemplate = asset as GameObject;
            },
                                         //加载失败的回调
                                         (assetName, status, errorMessage, userData) =>
            {
                HotLog.Error("Can not load HPBarItem from '{0}' with error message '{1}'.", assetName, errorMessage);
            });
        }
예제 #11
0
        public override void OnShow(object userData)
        {
            base.OnShow(userData);

            //缓存我的战机数据
            m_MyAircraftData = userData as MyAircraftData;
            if (m_MyAircraftData == null)
            {
                HotLog.Error("My aircraft data is invalid.");
                return;
            }

            ScrollableBackground sceneBackground = (ScrollableBackground)Object.FindObjectOfType(typeof(ScrollableBackground));

            if (sceneBackground == null)
            {
                HotLog.Warning("Can not find scene background.");
                return;
            }
            //创建移动区域
            m_PlayerMoveBoundary = new Rect(sceneBackground.PlayerMoveBoundary.bounds.min.x, sceneBackground.PlayerMoveBoundary.bounds.min.z,
                                            sceneBackground.PlayerMoveBoundary.bounds.size.x, sceneBackground.PlayerMoveBoundary.bounds.size.z);
        }