예제 #1
0
        private void CreateRails()
        {
            FVec3 worldOffset =
                this._maze.LocalPointToGlobalPoint(new FVec3(this._maze.startPointPlace[0] * Fix64.Half, Fix64.Zero,
                                                             this._maze.startPointPlace[1] * Fix64.Half));
            FVec3 center = this._maze.centerOfStartRange;

            FVec3[] positions = new FVec3[4];
            positions[0] = new FVec3(center.x, center.y, center.z + worldOffset.z);
            positions[1] = new FVec3(center.x + worldOffset.x, center.y, center.z);
            positions[2] = new FVec3(center.x, center.y, center.z - worldOffset.z);
            positions[3] = new FVec3(center.x - worldOffset.x, center.y, center.z);

            FVec3[] offset = new FVec3[4];
            offset[0] = new FVec3(0, 0, 0.5f);
            offset[1] = new FVec3(0.5f, 0, 0);
            offset[2] = new FVec3(0, 0, -0.5f);
            offset[3] = new FVec3(-0.5f, 0, 0);

            FVec3[] directions = new FVec3[4];
            directions[0] = FVec3.backward;
            directions[1] = FVec3.left;
            directions[2] = FVec3.forward;
            directions[3] = FVec3.right;

            for (int i = 0; i < 4; i++)
            {
                EntityParam param = new EntityParam();
                param.rid       = (i % 2 == 0 ? "_c0@" : "_c0_1@") + i;
                param.position  = positions[i];
                param.direction = directions[i];
                Rail rail = this._entityManager.Create <Rail>(param);
                rail.position += offset[i] * rail.bounds.size;
            }
        }
예제 #2
0
        private void CreatePlayers(BattleParams.Player[] players)
        {
            FVec3 worldOffset =
                this._maze.LocalPointToGlobalPoint(new FVec3(this._maze.startPointPlace[0] * Fix64.Half, Fix64.Zero,
                                                             this._maze.startPointPlace[1] * Fix64.Half));
            FVec3 center = this._maze.centerOfStartRange;
            int   count  = players.Length;

            for (int i = 0; i < count; i++)
            {
                BattleParams.Player player = players[i];
                FVec2       rndCircle      = this._random.onUnitCircle;
                EntityParam entityParam    = new EntityParam
                {
                    rid      = player.cid + "@" + player.id,
                    uid      = player.id,
                    skin     = player.skin,
                    team     = player.team,
                    position = new FVec3(this._random.NextFix64(center.x - worldOffset.x, center.x + worldOffset.x),
                                         center.y,
                                         this._random.NextFix64(center.z - worldOffset.z, center.z + worldOffset.z)),
                    direction = new FVec3(rndCircle.x, Fix64.Zero, rndCircle.y)
                };
                Champion champion = this._entityManager.Create <Champion>(entityParam);
                champion.position = this.maze.RestrictInBounds(champion, true);
            }
        }
예제 #3
0
        public T Create <T>(EntityParam param) where T : Entity, new()
        {
            T entity = this._gPool.Pop <T>();

            this._idToEntity[param.rid] = entity;
            this._entities.Add(entity);

            System.Type t = typeof(T);
            if (typeof(Collider).IsAssignableFrom(t))
            {
                Collider collider = entity as Collider;
                this._colliders.Add(collider);
            }
            if (typeof(ITrigger).IsAssignableFrom(t))
            {
                ITrigger trigger = entity as ITrigger;
                this._triggers.Add(trigger);
            }
            if (typeof(Item).IsAssignableFrom(t))
            {
                Item item = entity as Item;
                this._idToItem[param.rid] = item;
                this._items.Add(item);
            }
            if (typeof(Champion).IsAssignableFrom(t))
            {
                Champion champion = entity as Champion;
                this._idToChampion[param.rid] = champion;
                this._champions.Add(champion);
            }
            SyncEvent.CreateEntity(entity.GetType().Name, param);
            entity.OnAddedToBattle(this._battle, param);
            return(entity);
        }
예제 #4
0
        public Missile CreateMissile(string id, Vec3 position, Vec3 direction)
        {
            EntityParam param = new EntityParam();

            param.rid       = this._random.IdHash(id);
            param.position  = position;
            param.direction = direction;
            param.team      = -1;
            return(this._entityManager.CreateMissile(param));
        }
예제 #5
0
        public T CreateBio <T>(string id, Vec3 position, Vec3 direction, int team) where T : Bio, new()
        {
            EntityParam param = new EntityParam();

            param.rid       = this._random.IdHash(id);
            param.position  = position;
            param.direction = direction;
            param.team      = team;
            return(this._entityManager.CreateBio <T>(param));
        }
예제 #6
0
        private void CreateTerminus()
        {
            FVec3 endPos = this._maze.IndexToCoord(this._maze.endIndex);

            endPos.x += Fix64.Half;
            endPos.z -= Fix64.Half;
            endPos    = this._maze.LocalPointToGlobalPoint(endPos);
            EntityParam param = new EntityParam();

            param.rid       = this._random.IdHash("_c0_2");
            param.position  = endPos;
            param.direction = FVec3.forward;
            Terminus terminus = this._entityManager.Create <Terminus>(param);
        }
예제 #7
0
        protected override void InternalOnAddedToBattle(EntityParam param)
        {
            base.InternalOnAddedToBattle(param);

            this.uid              = param.uid;
            this.team             = param.team;
            this.fov              = this._data.fov;
            this.speed            = Fix64.Zero;
            this.velocity         = FVec3.zero;
            this.moveSpeedFactor  = Fix64.One;
            this.mazeResult       = MazeResult.Nan;
            this._movingDirection = FVec3.zero;

            this._fsm.Start();
            this.ChangeState(FSMStateType.Idle);
        }
예제 #8
0
        private void CreatePlayers(BattleParams battleParams)
        {
            int count = battleParams.players.Length;

            for (int i = 0; i < count; i++)
            {
                BattleParams.Player player = battleParams.players[i];
                EntityParam         param  = new EntityParam();
                param.rid       = player.cid + "@" + player.id;
                param.uid       = player.id;
                param.position  = this.RandomPoint(this.data.bornPos1, this.data.bornRange);
                param.direction = this.data.bornDir1;
                param.team      = player.team;
                this._entityManager.CreateBio(param);
            }
        }
예제 #9
0
        public Item CreateItem(string rid, FVec3 position, FVec3 direction)
        {
            EntityParam entityParam = new EntityParam
            {
                rid       = rid,
                uid       = string.Empty,
                team      = -1,
                position  = position,
                direction = direction
            };
            Item item = this._entityManager.Create <Item>(entityParam);

            item.position        = this._maze.RestrictInBounds(item, false);
            item.enableCollision = false;
            return(item);
        }