Exemplo n.º 1
0
 private bool IsUntouchable(SceneObjectEntity sceneObj, PlayerEntity player)
 {
     if (sceneObj.hasUnityObject)
     {
         if (IsUntouchableOffGround(player, sceneObj.position.Value, sceneObj.unityObject.UnityObject))
         {
             return(true);
         }
     }
     else if (sceneObj.hasMultiUnityObject)
     {
         if (null != sceneObj.multiUnityObject.FirstAsset)
         {
             if (IsUntouchableOffGround(player, sceneObj.position.Value, sceneObj.multiUnityObject.FirstAsset as GameObject))
             {
                 return(true);
             }
         }
         else
         {
             Logger.Error("no first asset in multiUnityObject");
         }
     }
     else
     {
         Logger.Error("secneobj has no gameobject");
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        public static RayCastTarget Assemble(GameObject model, SceneObjectEntity entity)
        {
            var needRotate = false;

            if (entity.hasSimpleEquipment)
            {
                var isWeaponPart = entity.simpleEquipment.Category == (int)ECategory.WeaponPart;
                var isWeapon     = entity.simpleEquipment.Category == (int)ECategory.Weapon;
                var isC4         = SingletonManager.Get <WeaponResourceConfigManager>().IsC4(entity.simpleEquipment.Id);
                needRotate = isWeaponPart || (isWeapon && !isC4);
            }
            else if (entity.hasWeaponObject)
            {
                var isC4 = SingletonManager.Get <WeaponResourceConfigManager>().IsC4(entity.weaponObject.ConfigId);
                needRotate = !isC4;
            }
            else
            {
                Logger.Error("illegal sceneobject has no weapon or equip component ");
            }
            if (needRotate)
            {
                model.transform.localRotation = Quaternion.Euler(0, 0, -90);
            }
            else
            {
                model.transform.localRotation = Quaternion.identity;
            }
            var root = BaseGoAssemble.Assemble(model, entity.position.Value, entity.entityKey.Value.ToString(), needRotate);

            model.transform.localScale = Vector3.one;
            return(root);
        }
Exemplo n.º 3
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player  = GetPlayerEntity(args);
            Vector3      dropPos = UnityPositionUtil.ToVector3(pos.Select(args));

            if (player != null)
            {
                RaycastHit hit;
                Ray        ray = new Ray(player.position.Value, dropPos);
                if (Physics.Raycast(ray, out hit, Vector3.Distance(player.position.Value, dropPos), UnityLayers.SceneCollidableLayerMask))
                {
                    RaycastHit vhit;
                    if (Physics.Raycast(hit.point, Vector3.down, out vhit, 10000, UnityLayers.SceneCollidableLayerMask))
                    {
                        dropPos = vhit.point;
                    }
                    else
                    {
                        dropPos = hit.point;
                    }
                }
            }
            SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), dropPos);

            if (entity != null && !string.IsNullOrEmpty(time))
            {
                entity.AddLifeTime(DateTime.Now, args.GetInt(time));
            }
            Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args));
        }
Exemplo n.º 4
0
        private void AssembleWeapon(SceneObjectEntity entity)
        {
            var weaponGo      = entity.multiUnityObject.FirstAsset;
            var partAssetDict = entity.weaponAttachment.PartAssetDict;

            //var attachResList = entity.weaponAttachment.AttachResList;
            // if (attachResList.Count > 0 && attachResList[0] is Material)
            // {
            //     Material newMat = GameObject.Instantiate(attachResList[0] as Material);
            //     var renderAssy = weaponGo.GetComponentsInChildren<MeshRenderer>();
            //     foreach (var render in renderAssy)
            //     {
            //         render.sharedMaterial = newMat;
            //         render.enabled = true;
            //     }
            // }
            foreach (var keyPartAssetData in partAssetDict)
            {
                if (keyPartAssetData.Value.UnityObject && keyPartAssetData.Value.PartLocation != WeaponPartLocation.EndOfTheWorld)
                {
                    boneMountUtil.MountWeaponAttachment(keyPartAssetData.Value.UnityObject,
                                                        weaponGo, keyPartAssetData.Value.PartLocation);
                }
                else
                {
                    SceneObjectLoadSystem.Logger.ErrorFormat("Location is illegal with item type {0}", keyPartAssetData.Value);
                }
                // entity.weaponAttachment.EffectAssetList.ForEach(
                //     effectGo =>
                //     {
                //         if (effectGo != null && effectGo.AsGameObject)
                //             effectGo.AsGameObject.transform.position = entity.position.Value;
                //     });
            }
        }
Exemplo n.º 5
0
            private void AssembleWeapon(SceneObjectEntity entity)
            {
                var weaponGo = entity.multiUnityObject.FirstAsset;

                if (entity.hasWeaponAttachment)
                {
                    var dic = entity.weaponAttachment.AttachmentDic;
                    foreach (var pair in dic)
                    {
                        var attachGo = entity.multiUnityObject.LoadedAssets[pair.Key];
                        var location = WeaponPartLocation.EndOfTheWorld;
                        location = WeaponTypeConvertUtil.GetLocationByPartType((EWeaponPartType)pair.Value);
                        if (location != WeaponPartLocation.EndOfTheWorld)
                        {
                            _boneMount.MountWeaponAttachment(attachGo, weaponGo, location);
                        }
                        else
                        {
                            Logger.ErrorFormat("Location is illegal with item type {0}", pair.Value);
                        }
                    }

                    var effectDic = entity.weaponAttachment.EffectDic;
                    if (effectDic.Count > 0)
                    {
                        foreach (var effect in effectDic)
                        {
                            var attachGo = entity.multiUnityObject.LoadedAssets[effect];
                            attachGo.AsGameObject.transform.position = entity.position.Value;
                        }
                    }
                }
            }
Exemplo n.º 6
0
        public void AutoPickupWeapon(PlayerEntity player, int sceneKey)
        {
            SceneObjectEntity sceneEntity = sceneObjectEntityFactory.GetSceneEntity(sceneKey) as SceneObjectEntity;

            if (sceneEntity == null || !sceneEntity.IsCanPickUpByPlayer(player))
            {
                return;
            }
            var  newWeaponScan = (WeaponScanStruct)sceneEntity.weaponObject;
            bool pickupResult  = player.WeaponController().AutoPickUpWeapon(newWeaponScan);

            if (!pickupResult)
            {
                return;
            }
            sceneObjectEntityFactory.DestroySceneWeaponObjectEntity(sceneEntity.entityKey.Value);
            IEventArgs args = commonSession.FreeArgs as IEventArgs;

            if (null != args)
            {
                TriggerArgs ta = new TriggerArgs();
                ta.AddPara(new IntPara("weaponId", sceneEntity.weaponObject.ConfigId));
                ta.AddUnit("current", (FreeData)player.freeData.FreeData);
                args.Trigger(FreeTriggerConstant.WEAPON_PICKUP, ta);
            }
        }
Exemplo n.º 7
0
            private void ProcessSimpleEquipment(SceneObjectEntity entity, RayCastTarget target)
            {
                var equip    = entity.simpleEquipment;
                var category = entity.simpleEquipment.Category;
                var entityId = entity.entityKey.Value.EntityId;

                SceneObjCastData.Make(target, entityId, equip.Id, equip.Count, category);
                switch ((ECategory)category)
                {
                case ECategory.Weapon:
                    var weaponCfg = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(equip.Id);
                    if (null == weaponCfg)
                    {
                        break;
                    }

                    var weaponType = (EWeaponType_Config)weaponCfg.Type;
                    if (weaponType.CanAutoPick())
                    {
                        EnableAutoPickup(entityId, target.gameObject);
                    }

                    break;

                default:
                    break;
                }
            }
Exemplo n.º 8
0
        public void OnLoadTextAssetSucess(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (unityObj.AsObject == null || entity == null)
            {
                entity.multiUnityObject.loadingAssetInfos.Remove(unityObj.Address);
                CheckLoadingState(entity);
                return;
            }
            if (entity.multiUnityObject.loadingAssetInfos.Remove(unityObj.Address))
            {
                entity.multiUnityObject.LoadedAssets[unityObj.Address] = unityObj;
                if (unityObj.AsObject)
                {
                    entity.multiUnityObject.LoadedAssets[unityObj.Address] = unityObj;
                }
                else
                {
                    SceneObjectLoadSystem.Logger.ErrorFormat("asset {0}  as AsObject missing ",
                                                             unityObj.Address);
                }
            }
            else
            {
                SceneObjectLoadSystem.Logger.ErrorFormat("asset {0} should not be treated as multi asset ",
                                                         unityObj.Address);
            }

            CheckLoadingState(entity);
        }
Exemplo n.º 9
0
 public static bool IsCanPickUpByPlayer(this SceneObjectEntity sceneObjectEntity, PlayerEntity playerEntity)
 {
     if (!sceneObjectEntity.hasCastFlag)
     {
         return(true);
     }
     return(PlayerStateUtil.HasCastState((EPlayerCastState)sceneObjectEntity.castFlag.Flag, playerEntity.gamePlay));
 }
Exemplo n.º 10
0
 private void CheckLoadingState(SceneObjectEntity entity)
 {
     if (entity.multiUnityObject.loadingAssetInfos.Count == 0)
     {
         AssembleWeapon(entity);
         // 完成
         ProcessSceneObjectSetting(entity, entity.multiUnityObject.FirstAsset);
     }
 }
Exemplo n.º 11
0
        public void OnLoadUnityObjectSucess(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (!Verify(entity, unityObj))
            {
                return;
            }

            entity.AddUnityObject(unityObj);

            AppearanceUtils.EnableRender(unityObj.AsGameObject);
            ProcessSceneObjectSetting(entity, unityObj.AsGameObject);
        }
Exemplo n.º 12
0
        private static void AddRawGameObject(IEntity obj, GameObject gameObject)
        {
            SceneObjectEntity sceneObject = obj as SceneObjectEntity;

            sceneObject.AddRawGameObject(gameObject);
            var entityReference = gameObject.GetComponent <EntityReference>();

            if (entityReference == null)
            {
                entityReference = gameObject.AddComponent <EntityReference>();
            }
            entityReference.Init(sceneObject.entityAdapter);
        }
Exemplo n.º 13
0
            public void OnLoadSucc(SceneObjectEntity entity, UnityObject unityObj)
            {
                if (null == entity)
                {
                    Logger.Error("Entity type mismatched !!");
                    return;
                }

                var model = unityObj.AsGameObject;

                if (null == model)
                {
                    Logger.Error("Resource load type mismatched");
                    return;
                }

                if (!entity.hasMultiUnityObject)
                {
                    Logger.Error("MultiUnityObject component is needed !");
                    return;
                }

                if (entity.multiUnityObject.LoadedAssets.ContainsKey(unityObj.Address))
                {
                    entity.multiUnityObject.LoadedAssets[unityObj.Address] = unityObj;
                    AppearanceUtils.EnableRender(model);
                }
                else
                {
                    Logger.ErrorFormat("asset {0} should not be treated as multi asset ", unityObj.Address);
                }

                bool finished = true;

                foreach (var loaded in entity.multiUnityObject.LoadedAssets)
                {
                    if (null == loaded.Value)
                    {
                        finished = false;
                    }
                }

                if (!finished)
                {
                    return;
                }

                AssembleWeapon(entity);
                // 完成
                InitSceneObject(entity, entity.multiUnityObject.FirstAsset);
            }
Exemplo n.º 14
0
        public override void DoAction(IEventArgs args)
        {
            SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args),
                FreeUtil.ReplaceInt(id, args),
                FreeUtil.ReplaceInt(count, args),
                UnityPositionUtil.ToVector3(pos.Select(args)));

            if (entity != null && !string.IsNullOrEmpty(time))
            {
                entity.AddLifeTime(DateTime.Now, args.GetInt(time));
            }
            Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args));
        }
Exemplo n.º 15
0
        protected override bool Verify(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (!base.Verify(entity, unityObj))
            {
                return(false);
            }
            if (!entity.hasMultiUnityObject)
            {
                SceneObjectLoadSystem.Logger.Error("MultiUnityObject component is needed !");
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
 private bool HasNoObstacle(SceneObjectEntity item, PlayerEntity player)
 {
     if (item.hasUnityObject)
     {
         return(!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, item.unityObject.UnityObject));
     }
     else if (item.hasMultiUnityObject)
     {
         return(!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, item.multiUnityObject.FirstAsset));
     }
     else
     {
         return(!CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, item.position.Value, null));
     }
 }
Exemplo n.º 17
0
            private void ProcessWeapon(SceneObjectEntity entity, RayCastTarget target)
            {
                var weapon   = entity.weaponObject;
                var entityId = entity.entityKey.Value.EntityId;

                SceneObjCastData.Make(target, entityId, weapon.ConfigId, 1, (int)ECategory.Weapon);
                var weaponType = (EWeaponType_Config)SingletonManager
                                 .Get <WeaponResourceConfigManager>().GetConfigById(weapon.ConfigId)
                                 .Type;

                if (weaponType.CanAutoPick())
                {
                    EnableAutoPickup(entityId, target.gameObject);
                }
            }
Exemplo n.º 18
0
        private void ProcessWeaonCastSetting(SceneObjectEntity entity, RayCastTarget target)
        {
            var weapon   = entity.weaponObject;
            var entityId = entity.entityKey.Value.EntityId;

            SceneObjCastData.Make(target, entityId, weapon.ConfigId, entity.hasSimpleItem ? entity.simpleItem.Count : 1, (int)ECategory.Weapon);

            /*var weaponType = (EWeaponType_Config) SingletonManager
             *                                    .Get<WeaponResourceConfigManager>().GetConfigById(weapon.ConfigId)
             *                                    .Type;
             * if (weaponType.CanAutoPick())
             * {
             *  EnableAutoPickup(entityId, target.gameObject);
             * }*/
        }
Exemplo n.º 19
0
        public virtual void AutoPickupWeapon(PlayerEntity player, List <int> sceneKeys)
        {
            for (int i = 0; i < sceneKeys.Count; i++)
            {
                SceneObjectEntity sceneEntity = sceneObjectEntityFactory.GetSceneEntity(sceneKeys[i]) as SceneObjectEntity;
                //sceneKeys.Remove(sceneKeys[i]);
                if (sceneEntity == null || !sceneEntity.hasWeaponObject)
                {
                    Logger.Warn("sceneEntity null failed");
                    return;
                }

                EWeaponType_Config configType = (EWeaponType_Config)SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(sceneEntity.weaponObject.ConfigId).Type;
                if (!configType.CanAutoPick())
                {
                    Logger.Warn("CanAutoPick failed");
                    return;
                }
                if (configType == EWeaponType_Config.TacticWeapon && !sceneEntity.IsCanPickUpByPlayer(player))
                {
                    Logger.Warn("IsCanPickUpByPlayer failed");
                    return;
                }

                var  newWeaponScan = (WeaponScanStruct)sceneEntity.weaponObject;
                bool pickupResult  = player.WeaponController().AutoPickUpWeapon(newWeaponScan);
                if (!pickupResult)
                {
                    Logger.Warn("pickupResult failed");
                    return;
                }

                sceneObjectEntityFactory.DestroySceneWeaponObjectEntity(sceneEntity.entityKey.Value);
                if (player.WeaponController().HeldConfigId == sceneEntity.weaponObject.ConfigId)
                {
                    player.stateInterface.State.PickUp();
                }

                IEventArgs args = commonSession.FreeArgs as IEventArgs;
                if (null != args)
                {
                    TriggerArgs ta = new TriggerArgs();
                    ta.AddPara(new IntPara("weaponId", sceneEntity.weaponObject.ConfigId));
                    ta.AddUnit("current", (FreeData)player.freeData.FreeData);
                    args.Trigger(FreeTriggerConstant.WEAPON_PICKUP, ta);
                }
            }
        }
Exemplo n.º 20
0
        public void OnLoadEffectObjetSucess(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (!Verify(entity, unityObj))
            {
                CheckLoadingState(entity);
                return;
            }
            entity.multiUnityObject.CacheAssetObject(unityObj);

            if (unityObj.AsGameObject != null)
            {
                entity.weaponAttachment.EffectAssetList.Add(unityObj);
                AppearanceUtils.EnableRender(unityObj.AsGameObject);
            }
            CheckLoadingState(entity);
        }
        public void AutoPickupWeapon(PlayerEntity player, List <int> sceneKeys)
        {
            for (int i = 0; i < sceneKeys.Count; i++)
            {
                SceneObjectEntity sceneEntity = sceneObjectEntityFactory.GetSceneEntity(sceneKeys[i]) as SceneObjectEntity;
                if (sceneEntity == null || !sceneEntity.hasWeaponObject || sceneEntity.isFlagDestroy)
                {
                    continue;
                }

                EWeaponType_Config configType = (EWeaponType_Config)SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(sceneEntity.weaponObject.ConfigId).Type;
                if (!configType.CanAutoPick())
                {
                    continue;
                }

                if (configType == EWeaponType_Config.TacticWeapon && !sceneEntity.IsCanPickUpByPlayer(player))
                {
                    continue;
                }

                var  newWeaponScan = (WeaponScanStruct)sceneEntity.weaponObject;
                bool pickupResult  = player.WeaponController().AutoPickUpWeapon(newWeaponScan);
                if (!pickupResult)
                {
                    continue;
                }

                sceneObjectEntityFactory.DestroySceneWeaponObjectEntity(sceneEntity.entityKey.Value);

                if (player.WeaponController().HeldConfigId == sceneEntity.weaponObject.ConfigId && SharedConfig.IsServer)
                {
                    PlayerAnimationAction.DoAnimation(null, PlayerAnimationAction.PickUp, player, true);
                }

                IEventArgs args = commonSession.FreeArgs as IEventArgs;
                if (null != args)
                {
                    TriggerArgs ta = new TriggerArgs();
                    ta.AddPara(new IntPara("weaponId", sceneEntity.weaponObject.ConfigId));
                    ta.AddUnit("current", (FreeData)player.freeData.FreeData);
                    args.Trigger(FreeTriggerConstant.WEAPON_PICKUP, ta);
                }
            }
        }
Exemplo n.º 22
0
        protected virtual bool Verify(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (null == entity)
            {
                SceneObjectLoadSystem.Logger.Error("Entity type mismatched !!");
                return(false);
            }

            var model = unityObj.AsGameObject;

            if (null == model)
            {
                SceneObjectLoadSystem.Logger.ErrorFormat("Resource load object mismatched {0}", unityObj.Address);
                entity.multiUnityObject.loadingAssetInfos.Remove(unityObj.Address);
                return(false);
            }
            return(true);
        }
Exemplo n.º 23
0
        public override void DoAction(IEventArgs args)
        {
            Debug.LogFormat("remove scene object {0}", id);
            SceneObjectEntity entity = args.GameContext.sceneObject.GetEntityWithEntityKey(new Core.EntityComponent.EntityKey(FreeUtil.ReplaceInt(id, args), (short)EEntityType.SceneObject));

            if (entity != null)
            {
                entity.isFlagDestroy = true;
            }
            else
            {
                FreeMoveEntity moveEntity = args.GameContext.freeMove.GetEntityWithEntityKey(new EntityKey(FreeUtil.ReplaceInt(id, args), (short)EEntityType.FreeMove));
                if (moveEntity != null)
                {
                    moveEntity.isFlagDestroy = true;
                }
            }
        }
Exemplo n.º 24
0
 public void OnLoadPartObjectSucess(SceneObjectEntity entity, UnityObject unityObj)
 {
     if (!Vertify(entity, unityObj))
     {
         CheckLoadingState(entity);
         return;
     }
     entity.multiUnityObject.CacheAssetObject(unityObj);
     if (unityObj.AsGameObject != null)
     {
         var partAssetData = entity.weaponAttachment.PartAssetDict[unityObj.Address];
         partAssetData.PartLocation = WeaponTypeConvertUtil.GetLocationByPartType((EWeaponPartType)partAssetData.PartSlotType);
         partAssetData.UnityObject  = unityObj;
         entity.weaponAttachment.PartAssetDict[unityObj.Address] = partAssetData;
         AppearanceUtils.EnableRender(unityObj.AsGameObject);
     }
     CheckLoadingState(entity);
 }
Exemplo n.º 25
0
        public static SimpleItemInfo GetGroundItemInfo(ServerRoom room, FreeData fd, string key)
        {
            SimpleItemInfo freeItem = new SimpleItemInfo();

            string[] xy = StringUtil.Split(key, ParaConstant.SPLITER_COMMA);
            if (xy.Length == 3)
            {
                string name = xy[0];
                int    x    = NumberUtil.GetInt(xy[1]);
                int    y    = NumberUtil.GetInt(xy[2]);

                if (x == 0)
                {
                    SceneObjectEntity entity = room.RoomContexts.sceneObject.GetEntityWithEntityKey(new EntityKey(y, (short)EEntityType.SceneObject));
                    if (entity != null)
                    {
                        freeItem.entityId = entity.entityKey.Value.EntityId;
                        freeItem.cat      = entity.simpleEquipment.Category;
                        freeItem.id       = entity.simpleEquipment.Id;
                        freeItem.count    = entity.simpleEquipment.Count;
                    }
                    else
                    {
                        FreeMoveEntity moveEntity = room.RoomContexts.freeMove.GetEntityWithEntityKey(new EntityKey(y, (short)EEntityType.FreeMove));
                        if (moveEntity != null)
                        {
                            SimpleItemInfo info = (SimpleItemInfo)SingletonManager.Get <DeadBoxParser>().FromString(moveEntity.freeData.Value);
                            freeItem.entityId = moveEntity.entityKey.Value.EntityId;
                            freeItem.cat      = info.cat;
                            freeItem.id       = info.id;
                            freeItem.count    = info.count;
                        }
                        else
                        {
                            Debug.LogErrorFormat("entity {0} not existed.", key);
                        }
                    }
                }
            }

            return(freeItem);
        }
Exemplo n.º 26
0
        public void OnLoadNecessaryObjectSucess(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (!Vertify(entity, unityObj))
            {
                CheckLoadingState(entity);
                return;
            }
            entity.multiUnityObject.CacheAssetObject(unityObj);
            if (unityObj.AsGameObject)
            {
                AppearanceUtils.EnableRender(unityObj.AsGameObject);
            }
            else
            {
                SceneObjectLoadSystem.Logger.ErrorFormat("asset {0}'s gameobject is null",
                                                         unityObj.Address);
            }

            CheckLoadingState(entity);
        }
Exemplo n.º 27
0
        private bool Vertify(SceneObjectEntity entity, UnityObject unityObj)
        {
            if (unityObj == null)
            {
                SceneObjectLoadSystem.Logger.Error("loaded unityObj is null");
                return(false);
            }

            if (entity == null)
            {
                SceneObjectLoadSystem.Logger.Error("Scene entity is null");
                return(false);
            }
            if (!entity.hasMultiUnityObject)
            {
                SceneObjectLoadSystem.Logger.Error("MultiUnityObject component is needed !");
                return(false);
            }

            return(true);
        }
Exemplo n.º 28
0
        /*private void EnableAutoPickup(int entityId, GameObject normalCollider)
         * {
         *  var listener = normalCollider.GetComponent<SceneObjectTriggerEnterListener>();
         *  if (listener == null)
         *  {
         *      listener = normalCollider.AddComponent<SceneObjectTriggerEnterListener>();
         *  }
         *  listener.SetEntityId(entityId);
         * }*/

        protected void ProcessSceneObjectSetting(SceneObjectEntity entity, GameObject model)
        {
            var target = SceneObjectGoAssemble.Assemble(model, entity);

            if (entity.hasEffects)
            {
                foreach (var effect in entity.effects.GlobalEffects)
                {
                    _effectManager.AddGameObject(effect, model);
                }
            }

            if (entity.hasWeaponObject)
            {
                ProcessWeaonCastSetting(entity, target);
            }
            else if (entity.hasSimpleItem)
            {
                ProcessSimpleEquipment(entity, target);
            }
        }
Exemplo n.º 29
0
        public void OnGamePlay()
        {
            if (entity == null || entity.isFlagDestroy)
            {
                entity = (SceneObjectEntity)_contexts.session.entityFactoryObject.SceneObjectEntityFactory
                         .CreateSimpleObjectEntity(
                    ECategory.GameItem,
                    104,
                    1,
                    RaycastUtility.GetLegalPosition(new UnityEngine.Vector3(0, 100, 0)));
            }
            else
            {
                var time = _contexts.session.currentTimeObject.CurrentTime;

                var p = time % 6000 / 6000f;

                entity.position.Value = new UnityEngine.Vector3(Mathf.Sin(360 * Mathf.Deg2Rad * p) * 5, 2, Mathf.Cos(360 * Mathf.Deg2Rad * p) * 5);
                entity.ReplaceFlagImmutability(_contexts.session.currentTimeObject.CurrentTime);
            }
        }
Exemplo n.º 30
0
        private void onFind(IGameEntity localEntity)
        {
            if (localEntity.EntityType != 6)
            {
                return;
            }

            SceneObjectEntity entity = fr.GameContext.sceneObject.GetEntityWithEntityKey(localEntity.EntityKey);

            if (entity != null && entity.hasSimpleItem && entity.simpleItem != null)
            {
                if (IsNear(entity.position.Value, _playerEntity.position.Value))
                {
                    CreateItemToPlayerAction action = new CreateItemToPlayerAction();
                    action.key  = FreeItemConfig.GetItemKey(entity.simpleItem.Category, entity.simpleItem.Id);
                    action.name = ChickenConstant.BagGround;

                    if (!string.IsNullOrEmpty(action.key))
                    {
                        action.count = entity.simpleItem.Count.ToString();
                        action.SetPlayer("current");
                        fr.TempUse("current", (FreeData)_playerEntity.freeData.FreeData);

                        action.Act(fr);

                        if (_ground.posList.Count > 0)
                        {
                            ItemPosition lastItem = _ground.posList[_ground.posList.Count - 1];
                            lastItem.GetKey().GetParameters()
                            .AddPara(new IntPara("entityId", entity.entityKey.Value.EntityId));
                        }

                        fr.Resume("current");
                    }
                }
            }
        }