コード例 #1
0
        public static string CreateConnectionString(EntitySetting setting, bool security = true, bool multi = true)
        {
            // Initialize the connection string builder for the
            // underlying provider.

            /*SqlConnectionStringBuilder sqlBuilder =
             *  new SqlConnectionStringBuilder();
             *
             * // Set the properties for the data source.
             * sqlBuilder.DataSource = setting.DataSource;
             * sqlBuilder.InitialCatalog = setting.DataCatalog;
             * if (!(string.IsNullOrEmpty(setting.Username) && string.IsNullOrEmpty(setting.Password)))
             * {
             *  sqlBuilder.UserID = setting.Username;
             *  sqlBuilder.Password = setting.Password;
             * }
             * sqlBuilder.IntegratedSecurity = security;
             * sqlBuilder.MultipleActiveResultSets = multi; //allows you to have multiple datareaders at once
             */
            string myConnectionString = "SERVER=localhost;" +
                                        "DATABASE=zep2;" +
                                        "UID=root;" +
                                        "PASSWORD=;";

            // Build the SqlConnection connection string.
            //return sqlBuilder.ToString();
            return(myConnectionString);
        }
コード例 #2
0
ファイル: EntityMgr.cs プロジェクト: yuanlipeng/LearnClinet
    public void Reset()
    {
        List <int> removeList = new List <int>();

        foreach (var item in mEntityCacheDict)
        {
            if (item.Value.hasEntityInfoComp == true)
            {
                EntitySetting entitySetting = EntitySetting.Setting[item.Value.entityInfoComp.ConfigId];
                AssetManager.Release(entitySetting.ResPath);
                if (item.Value.hasEntityRenderComp == true)
                {
                    GameObject.Destroy(item.Value.entityRenderComp.MainGo);
                }
            }
            removeList.Insert(0, item.Key);
        }

        for (int i = 0; i < removeList.Count; i++)
        {
            GameEntity entity = mEntityCacheDict[removeList[i]];
            mEntityCacheDict.Remove(removeList[i]);
            entity.Release(EntityMgr.Instance);
        }

        removeList.Clear();
        mEntityCacheDict.Clear();

        mContextsInstance.game.DestroyAllEntities();
    }
コード例 #3
0
ファイル: EntityMgr.cs プロジェクト: yuanlipeng/LearnClinet
    public GameEntity CreateBullet()
    {
        GameEntity    entity  = mContextsInstance.game.CreateEntity();
        EntitySetting setting = EntitySetting.Setting[13];

        entity.AddEntityInfoComp(mBulletIndex, setting.EntityType, 13);
        entity.AddEntityBulletMoveComp(setting.BornPos, 0, setting.MoveSpeed, false);
        entity.AddBoxColliderComp(setting.BoxColliderR);

        mEntityCacheDict[mBulletIndex] = entity;
        entity.Retain(EntityMgr.Instance);

        AssetManager.LoadGameObject <GameObject>(setting.ResPath, (UnityEngine.Object obj) =>
        {
            if (entity.retainCount > 0)
            {
                GameObject model = GameObject.Instantiate <GameObject>((GameObject)obj);
                model.transform.SetParent(mHintRoot.transform);
                entity.AddEntityRenderComp((GameObject)model);
            }
        });

        mBulletIndex++;

        return(entity);
    }
コード例 #4
0
 private void numSettingB_ValueChanged(object sender, EventArgs e)
 {
     if (!settingdirty)
     {
         EntitySetting s = entity.Settings[settingindex];
         entity.Settings[settingindex] = new EntitySetting(s.ValueA, (int)numSettingB.Value);
     }
 }
コード例 #5
0
 private void numSettingA_ValueChanged(object sender, EventArgs e)
 {
     if (!settingdirty)
     {
         EntitySetting s = entity.Settings[settingindex];
         entity.Settings[settingindex] = new EntitySetting((byte)numSettingA.Value, s.ValueB);
     }
 }
コード例 #6
0
ファイル: ServiceSetting.cs プロジェクト: cocoon/Toec
        public DtoActionResult UpdateSettingValue(EntitySetting setting)
        {
            var actionResult = new DtoActionResult();

            _uow.SettingRepository.Update(setting, setting.Id);
            _uow.Save();
            actionResult.Success = true;
            actionResult.Id      = setting.Id;
            return(actionResult);
        }
コード例 #7
0
    private bool searchMonster(GameEntity monster)
    {
        EntitySetting        setting      = EntitySetting.Setting[monster.entityInfoComp.Id];
        Vector3              bornPos      = setting.BornPos;
        Vector3              monsterPos   = monster.moveComp.CurPos;
        float                minX         = bornPos.x - monster.entityAiComp.ScopeX;
        float                maxX         = bornPos.x + monster.entityAiComp.ScopeX;
        float                minY         = bornPos.z - monster.entityAiComp.ScopeY;
        float                maxY         = bornPos.z + monster.entityAiComp.ScopeY;
        Contexts             contexts     = EntityMgr.Instance.GetContexts();
        HashSet <GameEntity> gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.MainPlayer);

        foreach (var item in gameEntities)
        {
            Vector3 mainPlayerPos = item.moveComp.CurPos;
            if (mainPlayerPos.x >= minX && mainPlayerPos.x <= maxX && mainPlayerPos.z >= minY && mainPlayerPos.z <= maxY)
            {
                Vector3 dir = monsterPos - mainPlayerPos;
                if (dir.sqrMagnitude < 1.5f)
                {
                    //开始攻击
                    if (BattleCommandRuner.Instance.IsPuttingSkill(monster.entityInfoComp.Id) == false)
                    {
                        //Debug.LogError(" 开始攻击 " + monster.entityInfoComp.Id);
                        BattleCommand command = new BattleCommand();
                        command.CommandType          = BattleCommandType.PutSkill;
                        command.EntityId             = monster.entityInfoComp.Id;
                        command.PutSkillInfo         = new BattleCommand.CommandPutSkillInfo();
                        command.PutSkillInfo.SkillId = 101;
                        BattleLoop.Instance.AddCommand(command);
                    }
                }
                else
                {
                    //移动过去
                    Vector3 destPos = mainPlayerPos + Vector3.Normalize(dir);
                    //monster.moveComp.DestPos = destPos;
                    //monster.entityAiComp.IsAIEnded = false;
                    if (monster.moveComp.IsArrived == true)
                    {
                        BattleCommand command = new BattleCommand();
                        command.CommandType      = BattleCommandType.Move;
                        command.EntityId         = monster.entityInfoComp.Id;
                        command.MoveInfo         = new BattleCommand.CommandMoveInfo();
                        command.MoveInfo.DestPos = destPos;
                        BattleLoop.Instance.AddCommand(command);
                    }
                }
                return(true);
            }
        }
        return(false);
    }
コード例 #8
0
        public void Handle(object obj, string propertyName, string propertyValue, EntitySetting entitySetting)
        {
            object primaryKeyId = null;

            try
            {
                primaryKeyId = entitySetting.IdGeneration.Generator.Generator.Generate();
                ReflectionUtil.SetProperty(obj, propertyName, primaryKeyId);
            }
            catch (Exception ex)
            {
                throw new PrimaryKeyException(obj.GetType(), propertyName, primaryKeyId, ex);
            }
        }
コード例 #9
0
        public static string CreateEntityString(EntitySetting setting)
        {
            // Initialize the EntityConnectionStringBuilder.
            EntityConnectionStringBuilder entityBuilder =
                new EntityConnectionStringBuilder();

            //Set the provider name.
            entityBuilder.Provider = "MySql.Data.MySqlClient;";

            // Set the provider-specific connection string.
            entityBuilder.ProviderConnectionString = CreateConnectionString(setting);
            // Set the Metadata location.
            entityBuilder.Metadata = setting.Metadata;
            return(entityBuilder.ToString());
        }
コード例 #10
0
ファイル: EntityMgr.cs プロジェクト: yuanlipeng/LearnClinet
    public void ReturnEntity(GameEntity entity)
    {
        EntitySetting entitySetting = EntitySetting.Setting[entity.entityInfoComp.ConfigId];

        mEntityCacheDict.Remove(entity.entityInfoComp.Id);

        if (entity.hasEntityRenderComp == true)
        {
            GameObject.Destroy(entity.entityRenderComp.MainGo);
        }

        AssetManager.Release(entitySetting.ResPath);
        entity.Release(EntityMgr.Instance);
        entity.Destroy();
    }
コード例 #11
0
    public void Open()
    {
        EntitySetting.Init();
        BattleLoop.Instance.Init();
        EntityMgr.Instance.Init();
        SkillSetting.Init();

        ViewMgr.Instance.Open(ViewNames.Main);

        LoadScenePrefab();

        EntityMgr.Instance.CreateMainPlayer();
        EntityMgr.Instance.CreateMonster(2);
        EntityMgr.Instance.CreateMonster(3);
        EntityMgr.Instance.CreateMonster(4);
    }
コード例 #12
0
        public static bool CanHandle(string propertyName, EntitySetting entitySetting)
        {
            var isPrimaryKey = propertyName == entitySetting.PrimaryKey.PrimaryKeyName;

            if (isPrimaryKey && entitySetting.IdGeneration.IsGeneratorEnabled)
            {
                return(false);
            }

            if (isPrimaryKey && entitySetting.IdGeneration.IsDatabaseGenerationEnabled)
            {
                return(false);
            }

            return(true);
        }
コード例 #13
0
        public void Handle(object obj, string propertyName, string propertyValue, EntitySetting entitySetting)
        {
            try
            {
                var propertyType         = ReflectionUtil.GetPropertyType(obj.GetType(), propertyName);
                var simpleTransformation = _typeTransformationProvider.GetSimpleTransformation(propertyType);

                var typedPropertyValue = ReflectionUtil.IsNullableValueType(propertyType)
                    ? simpleTransformation.TransformNullable(propertyType, propertyValue)
                    : simpleTransformation.Transform(propertyType, propertyValue);

                ReflectionUtil.SetProperty(obj, propertyName, typedPropertyValue);
            }
            catch (Exception ex)
            {
                throw new PropertyTransformationException(obj.GetType(), propertyName, propertyValue, ex);
            }
        }
コード例 #14
0
ファイル: EntityMgr.cs プロジェクト: yuanlipeng/LearnClinet
    public GameEntity CreateEntity(int entityId)
    {
        GameEntity    entity  = mContextsInstance.game.CreateEntity();
        EntitySetting setting = EntitySetting.Setting[entityId];

        entity.AddEntityInfoComp(setting.EntityId, setting.EntityType, entityId);
        entity.AddMoveComp(setting.BornPos, setting.BornPos, setting.MoveSpeed, true, new Vector3(0, 0, 1), false, false);
        entity.AddBoxColliderComp(setting.BoxColliderR);

        mEntityCacheDict[entityId] = entity;
        entity.Retain(EntityMgr.Instance);

        AssetManager.LoadGameObject <GameObject>(setting.ResPath, (UnityEngine.Object obj) =>
        {
            GameObject model = GameObject.Instantiate <GameObject>((GameObject)obj);
            model.transform.SetParent(mHintRoot.transform);
            entity.AddEntityRenderComp((GameObject)model);
        });

        return(entity);
    }
コード例 #15
0
    private void updateAI(GameEntity entity)
    {
        if (entity.entityAiComp.IsAIEnded == true)
        {
            EntitySetting setting = EntitySetting.Setting[entity.entityInfoComp.Id];
            float         scopeX  = entity.entityAiComp.ScopeX;
            float         scopeY  = entity.entityAiComp.ScopeY;

            float randomX = Random.Range(-scopeX, scopeX);
            float randomY = Random.Range(-scopeY, scopeY);

            Vector3 destPos = new Vector3(setting.BornPos.x + randomX, setting.BornPos.y, setting.BornPos.z + randomY);
            //entity.moveComp.DestPos = destPos;
            //entity.moveComp.IsArrived = false;
            BattleCommand command = new BattleCommand();
            command.CommandType      = BattleCommandType.Move;
            command.EntityId         = entity.entityInfoComp.Id;
            command.MoveInfo         = new BattleCommand.CommandMoveInfo();
            command.MoveInfo.DestPos = destPos;
            BattleLoop.Instance.AddCommand(command);

            entity.entityAiComp.IsAIEnded = false;
        }
    }
コード例 #16
0
        public static bool CanHandle(string propertyName, EntitySetting entitySetting)
        {
            var isPrimaryKey = propertyName == entitySetting.PrimaryKey.PrimaryKeyName;

            // property should be primary key
            if (!isPrimaryKey)
            {
                return(false);
            }

            // generator should be enabled
            if (!entitySetting.IdGeneration.IsGeneratorEnabled)
            {
                return(false);
            }

            // database generator should be disabled
            if (entitySetting.IdGeneration.IsDatabaseGenerationEnabled)
            {
                return(false);
            }

            return(true);
        }
コード例 #17
0
        public void Handle(object obj, string propertyName, string propertyValue, EntitySetting entitySetting)
        {
            try
            {
                var propertyType = ReflectionUtil.GetPropertyType(obj.GetType(), propertyName);

                var referenceSetting = entitySetting.References.First(rd => rd.ReferenceName == propertyName);
                var foreignKeyId     = _idMappingProvider.GetRepositoryId(referenceSetting.ReferenceType, propertyValue);

                if (ReflectionUtil.IsReferenceType(propertyType))
                {
                    var referenceModel = entitySetting.Repository.LoadEntity(propertyType, foreignKeyId);
                    ReflectionUtil.SetProperty(obj, propertyName, referenceModel);
                }
                else
                {
                    ReflectionUtil.SetProperty(obj, propertyName, foreignKeyId);
                }
            }
            catch (Exception ex)
            {
                throw new ForeignKeyException(obj.GetType(), propertyName, propertyValue, ex);
            }
        }
コード例 #18
0
    public static void Init()
    {
        string monsterKey = "Assets/Hero Fighter/model/prefab/Fighter Devil.prefab";

        EntitySetting setting1 = new EntitySetting(1, new Vector3(0, 0, 0), EntityType.MainPlayer, 0.1f, 0.5f, "Assets/Hero Fighter/model/prefab/Fighter.prefab");

        Setting[1] = setting1;

        EntitySetting setting2 = new EntitySetting(2, new Vector3(-7.8f, 0, 2.5f), EntityType.Monster, 0.05f, 0.5f, monsterKey);

        Setting[2] = setting2;

        EntitySetting setting3 = new EntitySetting(3, new Vector3(9f, 0, 2.5f), EntityType.Monster, 0.05f, 0.5f, monsterKey);

        Setting[3] = setting3;

        EntitySetting setting4 = new EntitySetting(4, new Vector3(0f, 0, 8.0f), EntityType.Monster, 0.05f, 0.5f, monsterKey);

        Setting[4] = setting4;

        EntitySetting setting13 = new EntitySetting(13, new Vector3(1.0f, 0, 1.0f), EntityType.Bullet, 0.5f, 0.3f, "Assets/Hero Fighter/model/prefab/Cube.prefab");

        Setting[13] = setting13;
    }
コード例 #19
0
ファイル: CherrySeeder.cs プロジェクト: hur1can3/CherrySeed
 private List <object> Transform(Type type, List <Dictionary <string, string> > inputObjectDictionary,
                                 ObjectListTransformation objectListTransformation, EntitySetting entitySetting)
 {
     return(objectListTransformation.Transform(type, inputObjectDictionary, entitySetting));
 }
コード例 #20
0
        public List <object> Transform(Type type, List <Dictionary <string, string> > inputObjects, EntitySetting entitySetting)
        {
            var inputObjectList = inputObjects
                                  .Select(inputObject => _objectTransformation.Transform(inputObject, type, entitySetting))
                                  .ToList();

            return(inputObjectList);
        }
コード例 #21
0
 public DatabaseUpdater(EntitySetting pSettings, DatabaseTypes pType)
 {
     this._setting = pSettings;
     this._type    = pType;
 }
コード例 #22
0
 public static bool CanHandle(string propertyName, EntitySetting entitySetting)
 {
     return(entitySetting.References.Select(rd => rd.ReferenceName).Contains(propertyName));
 }
コード例 #23
0
ファイル: EntityFactory.cs プロジェクト: odasm/Noxus
        public static AccountEntity GetAccountEntity(EntitySetting setting)
        {
            string connectionstring = ConnectionStringBuilder.CreateEntityString(setting);

            return(new AccountEntity(connectionstring));
        }
コード例 #24
0
ファイル: EntityFactory.cs プロジェクト: Meeyars/Noxus
 public static WorldEntity GetWorldEntity(EntitySetting setting)
 {
     string connectionstring = ConnectionStringBuilder.CreateEntityString(setting);
     return new WorldEntity(connectionstring);
 }
コード例 #25
0
        public void Update()
        {
            this.svg.SelectAll("text").Remove();
            this.svg.SelectAll("image").Remove();

            link = link.Data((D3Element)(object)linkData,// null);
                             delegate(D3Element d) {
                string id = ((EntityLink)(object)d).Id;
                return(id);
            });
            node = node.Data((D3Element)(object)nodeData, delegate(D3Element d) {
                string id = ((Entity)(((EntityNode)(object)d).SourceData)).Id;

                return(id);
            });

            link.Enter()
            .Insert("svg:line", ".node")
            .Attr <Func <EntityLink, string> >("id", delegate(EntityLink d)
            {
                return(d.Id);
            })
            .Attr("class", "link");

            node.Enter().Append("svg:g")
            .Attr <Func <EntityNode, string> >("id", delegate(EntityNode d)
            {
                Entity entity = (Entity)d.SourceData;
                return(GetID(entity.Id));
            })
            .Attr("class", "node")
            .Attr("filter", "url(#blur1)")
            .On("click", delegate(D3Element d, int i)
            {
                HighlightNode(d);
                ShowInfoBox(d, true);
            })

            .On("mouseover", delegate(D3Element d, int i)
            {
                HighlightNode(d);
                if (!infoBoxPinned)
                {
                    ShowInfoBox(d, false);
                }
            })

            .On("mouseout", delegate(D3Element d, int i)
            {
                UnHighlightNode(d);
                if (stickyInfoBox || infoBoxPinned)
                {
                    return;
                }
                HideInfoBox();
            })
            .On("dblclick", delegate(D3Element d, int i)
            {
                d.Fixed = false;
                D3.Event.StopPropagation();

                // Expand overflow nodes if there any
                EntityNode entityNode = (EntityNode)(object)d;
                vm.ExpandOverflow(entityNode);
            })
            .Call(dragBehavior);


            node.Append("svg:image")
            .Attr("class", "chromeImage")
            .Attr <Func <EntityNode, string> >("xlink:href", delegate(EntityNode d)
            {
                Entity entity = ((Entity)d.SourceData);
                switch (entity.LogicalName)
                {
                case "account":
                case "contact":
                    return("../images/network.png");

                default:
                    return(null);
                }
            }
                                               )
            .Attr <Func <EntityNode, string> >("x", delegate(EntityNode d) { return(GetXY(d, 1.5)); })
            .Attr <Func <EntityNode, string> >("y", delegate(EntityNode d) { return(GetXY(d, 1.5)); })
            .Attr <Func <EntityNode, string> >("width", delegate(EntityNode d) { return(GetHeightWidth(d, 1.5)); })
            .Attr <Func <EntityNode, string> >("height", delegate(EntityNode d) { return(GetHeightWidth(d, 1.5)); })
            .Attr <Func <EntityNode, string> >("visibility", delegate(EntityNode d)
            {
                Entity entity = ((Entity)d.SourceData);
                switch (entity.LogicalName)
                {
                case "account":
                case "contact":
                    return(null);

                default:
                    return("hidden");
                }
            })
            .Attr <Func <EntityNode, string> >("filter", delegate(EntityNode d)
            {
                return(GetFilter(d));
            });

            node.Append("svg:image")
            .Attr("class", "entityImage")
            .Attr <Func <EntityNode, string> >("xlink:href", delegate(EntityNode d)
            {
                Entity entity = ((Entity)d.SourceData);
                switch (entity.LogicalName)
                {
                case "overflow":
                    return("../images/overflow.png");

                case "account":
                    return("../images/account.png");

                case "contact":
                    return("../images/contact.png");

                case "incident":
                    return("/_imgs/Navbar/ActionImgs/Cases_32.png");

                case "contract":
                    return("/_imgs/Navbar/ActionImgs/Contract_32.png");

                case "opportunity":
                    return("/_imgs/Navbar/ActionImgs/Opportunity_32.png");

                case "lead":
                    return("/_imgs/Navbar/ActionImgs/Lead_32.png");

                case "phonecall":
                    return("/_imgs/Navbar/ActionImgs/PhoneCall_32.png");

                case "email":
                    return("/_imgs/Navbar/ActionImgs/Email_32.png");

                case "task":
                    return("/_imgs/Navbar/ActionImgs/Task_32.png");

                case "appointment":
                    return("/_imgs/Navbar/ActionImgs/Appointment_32.png");

                default:
                    // Custom entity image
                    return("/_imgs/Navbar/ActionImgs/Documents_32.png");
                }
            })
            .Attr <Func <EntityNode, string> >("x", delegate(EntityNode d) { return(GetXY(d, 0.5)); })
            .Attr <Func <EntityNode, string> >("y", delegate(EntityNode d) { return(GetXY(d, 0.5)); })
            .Attr <Func <EntityNode, string> >("width", delegate(EntityNode d) { return(GetHeightWidth(d, 0.5)); })
            .Attr <Func <EntityNode, string> >("height", delegate(EntityNode d) { return(GetHeightWidth(d, 0.5)); })
            .Attr("filter", "url(#blur2)");

            node.Append("svg:text")
            .Attr("class", "nodetext")
            .Attr <Func <EntityNode, int> >("dx", delegate(EntityNode d)
            {
                Entity entity = ((Entity)d.SourceData);
                switch (entity.LogicalName)
                {
                case "overflow":
                    return(-3);

                default:
                    return(-15);
                }
            })
            .Attr <Func <EntityNode, int> >("dy", delegate(EntityNode d)
            {
                Entity entity = ((Entity)d.SourceData);
                switch (entity.LogicalName)
                {
                case "overflow":
                    return(3);

                default:
                    return(-15);
                }
            })
            .Text(delegate(EntityNode d)
            {
                Entity entity = (Entity)d.SourceData;
                if (entity.LogicalName == "overflow")
                {
                    if (d.Children != null)
                    {
                        return(d.Children.Count.ToString());
                    }
                    return("");
                }
                else
                {
                    EntitySetting entitySetting = vm.Config.Entities[entity.LogicalName];
                    // If there is no name attribute setting, we'll use the name attribute so you can add an alias.
                    string name = entity.GetAttributeValueString(entitySetting != null && entitySetting.NameAttribute != null ? entitySetting.NameAttribute : "name");
                    if (name != null && name.Length > 50)
                    {
                        name = name.Substr(0, 50) + "...";
                    }
                    return(name);
                }
            });

            // Exit any old links.
            this.link.Exit().Remove();
            this.node.Exit().Remove();
            force.Start();

            Dictionary <string, string> uniqueKeyCache = new Dictionary <string, string>();

            foreach (EntityLink l in vm.Links)
            {
                string id = l.Id;
                if (uniqueKeyCache.ContainsKey(id))
                {
                    Debug.WriteLine("Duplicate key " + id);
                }
                else
                {
                    uniqueKeyCache[id] = id;
                }
            }

            foreach (EntityNode l in vm.Nodes)
            {
                string id = ((Entity)(((EntityNode)(object)l).SourceData)).Id;

                if (uniqueKeyCache.ContainsKey(id))
                {
                    Debug.WriteLine("Duplicate key " + id);
                }
                else
                {
                    uniqueKeyCache[id] = id;
                }
            }
        }
コード例 #26
0
ファイル: EntityFactory.cs プロジェクト: odasm/Noxus
        public static WorldEntity GetWorldEntity(EntitySetting setting)
        {
            string connectionstring = ConnectionStringBuilder.CreateEntityString(setting);

            return(new WorldEntity(connectionstring));
        }
コード例 #27
0
        public object Transform(Dictionary <string, string> inputDictionary, Type outputType, EntitySetting entitySetting)
        {
            var outputObject = Activator.CreateInstance(outputType);

            // Set default values
            foreach (var defaultValueSetting in entitySetting.DefaultValueSettings)
            {
                var propertyName         = defaultValueSetting.PropertyName;
                var defaultValueProvider = defaultValueSetting.Provider;
                var defaultValue         = defaultValueProvider.GetDefaultValue();

                ReflectionUtil.SetProperty(outputObject, propertyName, defaultValue);
            }

            // Set values from data provider
            foreach (var inputKeyValuePair in inputDictionary)
            {
                var propertyName  = inputKeyValuePair.Key;
                var propertyValue = inputKeyValuePair.Value;

                _propertyHandler.SetProperty(outputObject, propertyName, propertyValue, entitySetting);
            }

            return(outputObject);
        }
コード例 #28
0
ファイル: DatabaseUpdater.cs プロジェクト: iFeddy/SolarFiesta
 public DatabaseUpdater(EntitySetting pSettings, DatabaseTypes pType)
 {
     this._setting = pSettings;
     this._type = pType;
 }
コード例 #29
0
    public void DoCommand(BattleCommand command)
    {
        int entityId = command.EntityId;

        if (command.CommandType == BattleCommandType.Move)
        {
            EntitySetting setting    = EntitySetting.Setting[entityId];
            GameEntity    gameEntity = EntityMgr.Instance.GetGameEntity(entityId);
            MoveComp      moveComp   = gameEntity.GetComponent(GameComponentsLookup.MoveComp) as MoveComp;
            moveComp.DestPos   = command.MoveInfo.DestPos;
            moveComp.IsArrived = false;
            moveComp.Speed     = setting.MoveSpeed;
            moveComp.IsAniMove = false;
            moveComp.Forward   = Vector3.Normalize(moveComp.DestPos - moveComp.CurPos);

            BattleCommand command1 = new BattleCommand();
            command1.CommandType         = BattleCommandType.PlayAni;
            command1.EntityId            = entityId;
            command1.PlayAniInfo         = new BattleCommand.CommandPlayAniInfo();
            command1.PlayAniInfo.AniName = "walk";
            BattleLoop.Instance.AddCommand(command1);
        }
        else if (command.CommandType == BattleCommandType.PutSkill)
        {
            SkillSetting   setting    = SkillSetting.SkillSettingDict[command.PutSkillInfo.SkillId];
            GameEntity     gameEntity = EntityMgr.Instance.GetGameEntity(entityId);
            MoveComp       moveComp   = gameEntity.GetComponent(GameComponentsLookup.MoveComp) as MoveComp;
            PutedSkillInfo skillInfo  = new PutedSkillInfo();

            skillInfo.EntityId     = entityId;
            skillInfo.PutSkillTime = Time.time;
            skillInfo.SkillId      = command.PutSkillInfo.SkillId;

            moveComp.Speed     = 0.1f;
            moveComp.IsAniMove = false;
            moveComp.IsBlock   = false;

            if (setting.IsBlockWalk == true)
            {
                moveComp.DestPos   = moveComp.CurPos;
                moveComp.IsArrived = true;
            }

            if (setting.IsNeedAniMove == true)
            {
                moveComp.Speed     = 0.5f;
                moveComp.IsArrived = false;
                moveComp.IsAniMove = true;
                moveComp.DestPos   = moveComp.CurPos + moveComp.Forward * 3.0f;
            }

            if (setting.IsBulletShoot == true)
            {
                moveComp.IsBlock = true;
                Timer.Instance.AddTimer(BattleTimerName.BulletMove, () =>
                {
                    Contexts contexts = EntityMgr.Instance.GetContexts();
                    HashSet <GameEntity> gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.Monster);
                    int monsterId = 1;
                    float dist    = 10000.0f;
                    foreach (var item in gameEntities)
                    {
                        float diff = (item.moveComp.CurPos - gameEntity.moveComp.CurPos).sqrMagnitude;
                        if (diff < dist)
                        {
                            dist      = diff;
                            monsterId = item.entityInfoComp.Id;
                        }
                    }

                    if (monsterId != 1)
                    {
                        GameEntity bullet = EntityMgr.Instance.CreateBullet();
                        bullet.entityBulletMoveComp.CurPos       = gameEntity.moveComp.CurPos + new Vector3(0, 2.0f, 0);
                        bullet.entityBulletMoveComp.DestEntityId = monsterId;
                        mPutedSkillInfos.Insert(0, skillInfo);
                    }

                    moveComp.IsBlock = false;

                    if (gameEntity.moveComp.IsArrived == false)
                    {
                        BattleCommand command2       = new BattleCommand();
                        command2.CommandType         = BattleCommandType.PlayAni;
                        command2.EntityId            = entityId;
                        command2.PlayAniInfo         = new BattleCommand.CommandPlayAniInfo();
                        command2.PlayAniInfo.AniName = "walk";
                        BattleLoop.Instance.AddCommand(command2);
                    }
                }, 0.6f, false);
            }
            else
            {
                mPutedSkillInfos.Insert(0, skillInfo);
            }

            BattleCommand command1 = new BattleCommand();
            command1.CommandType         = BattleCommandType.PlayAni;
            command1.EntityId            = entityId;
            command1.PlayAniInfo         = new BattleCommand.CommandPlayAniInfo();
            command1.PlayAniInfo.AniName = setting.AniName;
            BattleLoop.Instance.AddCommand(command1);
        }
        else if (command.CommandType == BattleCommandType.PlayAni)
        {
            if (command.PlayAniInfo.AniName.Equals("attacked") == true)
            {
                GameEntity gameEntity = EntityMgr.Instance.GetGameEntity(entityId);
                gameEntity.moveComp.IsArrived = true;
                Timer.Instance.AddTimer(BattleTimerName.AttackedTimer, () =>
                {
                    if (gameEntity.hasEntityAiComp == true)
                    {
                        gameEntity.entityAiComp.IsAIEnded = true;
                    }
                }, 1.0f, false);
            }

            BattleRenderCommand renderCommand = new BattleRenderCommand();
            renderCommand.EntityId = entityId;
            renderCommand.AniName  = command.PlayAniInfo.AniName;
            BattleRenderMgr.Instance.AddCommand(renderCommand);
        }
    }
コード例 #30
0
ファイル: EntityFactory.cs プロジェクト: Meeyars/Noxus
 public static AccountEntity GetAccountEntity(EntitySetting setting)
 {
     string connectionstring = ConnectionStringBuilder.CreateEntityString(setting);
     return new AccountEntity(connectionstring);
 }
コード例 #31
0
ファイル: PropertyHandler.cs プロジェクト: yejia21/CherrySeed
        public void SetProperty(object obj, string propertyName, string propertyValue, EntitySetting entitySetting)
        {
            foreach (var propertyHandlerPair in _strategyDictionary)
            {
                var x = propertyHandlerPair.Key(propertyName, entitySetting);

                if (x)
                {
                    propertyHandlerPair.Value.Handle(obj, propertyName, propertyValue, entitySetting);
                    return;
                }
            }
        }