Exemple #1
0
        /// <summary>
        /// The basic outline of the updateEntity method is as follows:
        /// 1, Have the entity perform the current action at the top of it's action queue (if any)
        /// 2, Check for changes in the entity's stats. (ex: check for death.)
        /// 3, Have the Entity react to any Events that occur within it's visibility range.
        /// (Events that either occur to the Entity or events that the Entity can "see")
        /// 4, Check if the Entity should be removed from the game. (When it's primary state is set to Remove.)
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="entitiesToRemove"></param>
        private void updateEntity(Entity entity, List <Entity> entitiesToRemove)
        {
            /*** Have entity perform it's current action (if any) ***/
            ActionController.Instance.update(entity, locController);

            Entity.EntityType type = entity.getEntityType();
            /*** Update stats of Entity ***/
            if (type == Entity.EntityType.Unit)
            {
                UnitStatsLogic.updateUnit((Unit)entity, curTick);
            }
            else
            {
                // Only Stats update occurs upon death of any StaticEntity right?
                if (entity.health <= 0)
                {
                    entity.getState().setPrimaryState(State.PrimaryState.Dead);
                }
            }

            /*** Have Entity react to any Events ***/
            if (type == Entity.EntityType.Unit)             // Only Units really need to react to Events.
            {
            }

            /*** Remove Entity if it needs to be removed. ***/
            if (entity.getState().getPrimaryState() == State.PrimaryState.Dead)             // Should be remove. Changed for demo.
            {
                entitiesToRemove.Add(entity);
            }
        }
Exemple #2
0
 public override void ValidateUrl()
 {
     base.ValidateUrl();
     short _typeID = 0;
     switch (Request.GroupString["type"]) {
         case "add":
             _typeID = Convert.ToInt16(Request.GroupString["id"]);
             break;
         case "edit":
             long _entityID = Convert.ToInt64(Request.GroupString["id"]);
             XiaoYang.Entity.EntityBase _base = XiaoYang.Entity.EntityBase.GetInstance(_entityID);
             if (_base == null) throw new Exception("can not found entity");
             _typeID = _base.TypeID;
             XiaoYang.Entity.EntityHelper _helper = new Entity.EntityHelper(_base.TypeID);
             XiaoYang.Entity.Entity _entity = new Entity.EntityCollection(_helper.Get(_entityID), _base.TypeID)[0];
             PageData.AddXyDataModel("Entity", _entity);
             break;
     }
     System.Data.DataTable _typeChain = Entity.EntityType.Get(_typeID);
     if (_typeChain.Rows.Count == 0) throw new Exception("can not found entity type");
     Entity.EntityType _type = new Entity.EntityType();
     _type.Fill(_typeChain.Rows[0]);
     while (_type.ParentTypeID > 0) {
         _type = Entity.EntityType.GetInstance(_type.ParentTypeID);
         System.Data.DataRow _newRow = _typeChain.NewRow();
         foreach (string _columnName in _type.GetAttributesName()) {
             _newRow[_columnName] = _type.GetAttributesValue(_columnName);
         }
         _typeChain.Rows.Add(_newRow);
     }
     _typeChain.DefaultView.Sort = "ID ASC";
     _typeChain = _typeChain.DefaultView.ToTable();
     PageData.AddXyDataModel("Type", _type);
     PageData.Add("TypeChain", _typeChain);
 }
Exemple #3
0
        public async Task SpawnEntity(string name, Entity.EntityType type, string prefabName, Vector3 position, Faction faction)
        {
            var newId = await _gameServerConnection.SendRequest <Eleon.Modding.Id>(Eleon.Modding.CmdId.Request_NewEntityId, null);

            var spawnInfo = new Eleon.Modding.EntitySpawnInfo();

            spawnInfo.forceEntityId = newId.id;
            spawnInfo.playfield     = this.Name;
            spawnInfo.pos           = position.ToPVector3();
            spawnInfo.rot           = new Eleon.Modding.PVector3();
            spawnInfo.name          = name;
            spawnInfo.type          = (byte)type;
            spawnInfo.prefabName    = prefabName;
            spawnInfo.factionGroup  = faction.Origin;
            spawnInfo.factionId     = faction.Id;
            //spawnInfo.exportedEntityDat = exportFile;

            await _gameServerConnection.SendRequest(Eleon.Modding.CmdId.Request_Entity_Spawn, spawnInfo);
        }
Exemple #4
0
        public async Task SpawnEntity(string name, Entity.EntityType type, string prefabName, Vector3 position, Player player)
        {
            var newId = await _gameServerConnection.SendRequest <Eleon.Modding.Id>(Eleon.Modding.CmdId.Request_NewEntityId, null);

            var spawnInfo = new Eleon.Modding.EntitySpawnInfo();

            spawnInfo.forceEntityId = newId.id;
            spawnInfo.playfield     = this.Name;
            spawnInfo.pos           = position.ToPVector3();
            spawnInfo.rot           = new Eleon.Modding.PVector3();
            spawnInfo.name          = name;
            spawnInfo.type          = (byte)type;
            spawnInfo.prefabName    = prefabName;
            spawnInfo.factionGroup  = player.FactionGroupId;
            spawnInfo.factionId     = player.EntityId;
            //spawnInfo.exportedEntityDat = exportFile;

            _gameServerConnection.DebugOutput("Creating entity for '{0}' of faction group '{1}', entity id '{2}' ", player, spawnInfo.factionGroup, spawnInfo.factionId);

            await _gameServerConnection.SendRequest(Eleon.Modding.CmdId.Request_Entity_Spawn, spawnInfo);
        }
Exemple #5
0
        protected EntityBase()
        {
            HotkeyString = "";

            Neutral = false;
            HasBeenViewed = false;
            Team = 0;

            Type = Entity.EntityType.Unit;
            BoundsSize = new Vector2f(20, 20);
            WorldId = 0;
            EntityToUse = null;
            WorldEntities = null;
            rallyPoints = new List<Entity.RallyPoint>();
            Health = 0;
            MaxHealth = 0;
            Position = new Vector2f();
            Energy = 0;
            MaxHealth = 0;
            EnergyRegenRate = 0;
            MyGameMode = null;
        }
        /// <summary>
        /// The basic outline of the updateEntity method is as follows:
        /// 1, Have the entity perform the current action at the top of it's action queue (if any)
        /// 2, Check for changes in the entity's stats. (ex: check for death.)
        /// 3, Have the Entity react to any Events that occur within it's visibility range.
        /// (Events that either occur to the Entity or events that the Entity can "see")
        /// 4, Check if the Entity should be removed from the game. (When it's primary state is set to Remove.)
        /// </summary>
        /// <param name="entity">Entity being updated.</param>
        /// <param name="entitiesToRemove">List of Entities to be removed.</param>
        private void updateEntity(Entity entity, List <Entity> entitiesToRemove)
        {
            /*** Have entity perform it's current action (if any) ***/
            ActionController.Instance.update(entity, locController);

            Entity.EntityType type  = entity.getEntityType();                   // Enity's type (Unit, Building, Object or Resource)
            State             state = entity.getState();                        // Entity's State.

            /*** Update stats of Entity ***/
            if (type == Entity.EntityType.Unit)
            {
                UnitStatsLogic.updateUnit((Unit)entity, curTick);
            }
            else
            {
                // Only Stats update occurs upon death of any StaticEntity right?
                if (entity.health <= 0)
                {
                    state.setPrimaryState(State.PrimaryState.Dead);
                    entity.tickKilled = curTick;
                }
            }

            /*** Have Entity react to any Events ***/
            if (type == Entity.EntityType.Unit)             // Only Units really need to react to Events.
            {
                GameEventLogic.processEvents((Unit)entity, scenario.getGameWorld());
            }


            /*** Remove Entity if it needs to be removed. ***/
            if (state.getPrimaryState() == State.PrimaryState.Dead)
            {
                entitiesToRemove.Add(entity);
            }
        }