Ejemplo n.º 1
0
        public ServerGameEntity Create(Vector3 position, ushort tmpPlayerId, int accountId,
                                       ViewTypeEnum viewTypeEnum, WarshipSO warshipSo)
        {
            warshipSoValidator.Validate(warshipSo);

            ServerGameEntity entity = gameContext.CreateEntity();

            entity.AddPlayer(tmpPlayerId);
            entity.AddNickname("warship");
            entity.AddAccount(accountId);
            entity.AddMaxSpeed(warshipSo.maxVelocity);
            entity.AddAngularVelocity(warshipSo.angularVelocity);
            if (warshipSo.maxHealth <= 0)
            {
                throw new Exception($"Нельзя спавнить корабли таких хп {warshipSo.maxHealth}");
            }

            entity.AddHealthPoints(warshipSo.maxHealth);
            entity.AddMaxHealthPoints(warshipSo.maxHealth);
            entity.AddTeam((byte)(tmpPlayerId + 1));
            entity.AddViewType(viewTypeEnum);
            entity.AddSpawnTransform(position, Quaternion.identity);

            return(entity);
        }
Ejemplo n.º 2
0
        public void CreateAsteroid(Vector3 position, ViewTypeEnum viewTypeEnum)
        {
            ServerGameEntity entity = contexts.serverGame.CreateEntity();

            entity.AddHealthPoints(500);
            entity.AddMaxHealthPoints(500);
            entity.AddViewType(viewTypeEnum);
            entity.AddSpawnTransform(position, Quaternion.identity);
        }