Exemple #1
0
        /// <summary>
        /// The convert to scene component.
        /// </summary>
        /// <param name="levelEntity">
        /// The level entity.
        /// </param>
        /// <param name="scene">
        /// The scene.
        /// </param>
        /// <returns>
        /// </returns>
        private SceneComponent ConvertToSceneComponent(LevelEntity levelEntity, Scene scene)
        {
            Type levelEntityType    = levelEntity.GetType();
            Type sceneComponentType = (from levelEntityTypeBinding in LevelScene.LevelEntityTypeBindings
                                       where levelEntityTypeBinding.LevelEntityType == levelEntityType
                                       select levelEntityTypeBinding.SceneComponentType).FirstOrDefault();

            if (sceneComponentType == null)
            {
                return(null);
            }

            Game game           = scene != null ? scene.Game : null;
            var  sceneComponent = (SceneComponent)Activator.CreateInstance(sceneComponentType, game);

            PropertyInfo[] levelEntityPropertyInfos = levelEntityType.GetProperties();
            foreach (PropertyInfo levelEntityPropertyInfo in levelEntityPropertyInfos)
            {
                PropertyInfo sceneComponentPropertyInfo = sceneComponentType.GetProperty(levelEntityPropertyInfo.Name);
                if (sceneComponentPropertyInfo == null)
                {
                    continue;
                }

                object levelEntityPropertyValue = levelEntityPropertyInfo.GetValue(levelEntity, null);
                sceneComponentPropertyInfo.SetValue(sceneComponent, levelEntityPropertyValue, null);
            }

            sceneComponent.SetScene(scene);
            return(sceneComponent);
        }
Exemple #2
0
    public void Save()
    {
        var pEntity = new PlayerEntity()
        {
            Position = picker.transform.position, Speed = 4
        };
        var lEntitiy = new LevelEntity()
        {
            CurrentProbCount  = LevelManager.CurrentSection.CurrentProbCount,
            ExpectedProbCount = LevelManager.CurrentSection.ExpectedProbCount,
            ActiveProbs       = LevelManager.CurrentSection.ActiveProbs.Select(x => new ProbEntity()
            {
                Position        = x.transform.position,
                Velocity        = x.GetComponent <Rigidbody>().velocity,
                AngularVelocity = x.GetComponent <Rigidbody>().angularVelocity,
                ProbType        = x.GetComponent <Probs>().ProbType,
            }).ToList(),
            CurrentLevel = LevelManager.CurrentLevel,
            LevelIndex   = LevelManager.CurrentSection.LevelIndex,
            Position     = LevelManager.CurrentSection.transform.position
        };

        var sEntity = new SaveEntity()
        {
            CurrentLevel = 0,
            LevelEntity  = lEntitiy,
            PlayerEntity = pEntity,
        };

        var json = JsonConvert.SerializeObject(sEntity);

        _savePath = Path.Combine(Application.persistentDataPath, "SaveData.json");
        File.WriteAllText(_savePath, json);
    }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Id,IsActive,CreDate")] LevelEntity levelEntity)
        {
            if (id != levelEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _levelRepository.UpdateAsync(levelEntity);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LevelEntityExists(levelEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(levelEntity));
        }
        /// <summary>
        /// Converts a <see cref="LevelEntity"/> data object into <see cref="Level"/> domain model.
        /// </summary>
        /// <returns>The <see cref="Level"/> domain model.</returns>
        /// <param name="levelEntity">The <see cref="LevelEntity"/> data object.</param>
        internal static Level ToDomainModel(this LevelEntity levelEntity)
        {
            Level level = new Level
            {
                Id               = levelEntity.Id,
                Name             = levelEntity.Name,
                Description      = levelEntity.Description,
                Size             = new Size2D(levelEntity.Width, levelEntity.Height),
                BackgroundColour = ColourTranslator.FromHexadecimal(levelEntity.BackgroundColour),
                Tiles            = new WorldTile[levelEntity.Width, levelEntity.Height]
            };

            foreach (TerrainInstanceEntity terrainInstance in levelEntity.Terrain)
            {
                if (level.Tiles[terrainInstance.LocationX, terrainInstance.LocationY] == null)
                {
                    level.Tiles[terrainInstance.LocationX, terrainInstance.LocationY] = new WorldTile();
                }

                level.Tiles[terrainInstance.LocationX, terrainInstance.LocationY].TerrainId = terrainInstance.TerrainId;
            }

            foreach (WorldObjectInstanceEntity worldObjectInstance in levelEntity.WorldObjects)
            {
                if (level.Tiles[worldObjectInstance.LocationX, worldObjectInstance.LocationY] == null)
                {
                    level.Tiles[worldObjectInstance.LocationX, worldObjectInstance.LocationY] = new WorldTile();
                }

                level.Tiles[worldObjectInstance.LocationX, worldObjectInstance.LocationY].WorldObjectId = worldObjectInstance.WorldObjectId;
            }

            return(level);
        }
Exemple #5
0
    //
    private void requestSubmitUserScores()
    {
        try
        {
            StringBuilder json = new StringBuilder("[");
            string        s    = GameConstants.JSON_LEVEL_SUBMIT;
            bool          isHaveLevelSubmit = false;

            for (int i = 0; i < SessionManager.Instance.UserInfo.Levels.Count; i++)
            {
                LevelEntity levelEntity = SessionManager.Instance.UserInfo.Levels[i + 1];
                if (levelEntity.Replay == 1)
                {
                    s = s.Replace("level_submit", "" + levelEntity.Level);
                    s = s.Replace("score_submit", "" + levelEntity.Level);
                    s = s.Replace("rate_submit", "" + levelEntity.Level);
                    json.Append(s);
                    json.Append(",");
                    isHaveLevelSubmit = true;
                }
            }

            if (isHaveLevelSubmit == true)
            {
                json = json.Remove(json.Length - 1, 1);
                json.Append("]");
                //RequestManager.Instance.requestSubmitUserScores (SessionManager.Instance.UserInfo.UserId, json.ToString(), SubmitScoreCallback, SubmitScoreError);
            }
        }
        catch (Exception ex)
        {
            Debug.LogWarning(ex.Message);
        }
    }
Exemple #6
0
    // Use this for initialization
    void Awake()
    {
        //First take care of singleton stuff

        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }

        character        = new Character(new Vector3(0, 0, 0));
        morphTriggers    = new Dictionary <Vector3, char>();
        teleportTriggers = new Dictionary <Vector3, Vector3>();
        moveTriggers     = new Dictionary <Vector3, char>();
        portalParticles  = Resources.Load("Portal", typeof(GameObject)) as GameObject;

        instance = this;
        DontDestroyOnLoad(this.gameObject);

        //Now load the game stuff

        levelLayout = new LevelEntity[20, 20, 20];
        for (int i = 0; i < 20; i++)
        {
            for (int j = 0; j < 20; j++)
            {
                for (int k = 0; k < 20; k++)
                {
                    levelLayout[i, j, k] = new LevelEntity(new Vector3(i, j, k));
                }
            }
        }

        restartGame();
    }
Exemple #7
0
    public void BuildLevelEntities(bool spawnMonsters)
    {
        for (int i = 0; i < map.things.Length; i++)
        {
            if (!map.things[i].multiplayer)
            {
                MultigenObject mobj = wad.multigen.GetObjectByDoomedNum(map.things[i].type);
                if (mobj != null)
                {
                    LevelEntity newObject = LevelEntity.SpawnEntity(
                        ThingSpawnPosition(map.things[i], true),
                        (float)map.things[i].angle,
                        mobj,
                        wad
                        );

                    if (!spawnMonsters && newObject.MF_COUNTKILL)
                    {
                        GameObject.Destroy(newObject.gameObject);
                    }
                    else
                    {
                        newObject.transform.parent = thingContainer;
                    }
                }
            }
        }
    }
 public PlayerGhostShield(LevelEntity owner) : base(false, false)
 {
     this.owner  = owner;
     this.sprite = TFGame.SpriteData.GetSpritePartInt("Shield");
     if (owner is PlayerGhost)
     {
         PlayerGhost ghost = owner as PlayerGhost;
         this.sprite.Color = ArcherData.GetColorB(ghost.PlayerIndex, ghost.Allegiance);
         if (ghost.Allegiance != Allegiance.Neutral)
         {
             this.particleType = Particles.TeamDash[(int)ghost.Allegiance];
         }
         else
         {
             this.particleType = Particles.Dash[ghost.PlayerIndex];
         }
     }
     else
     {
         this.sprite.Color = ArcherData.Enemies.ColorB;
         this.particleType = Particles.TeamDash[1];
     }
     this.sprite.Play(0, false);
     base.Add(this.sprite);
     this.sine = new SineWave(120);
     base.Add(this.sine);
 }
Exemple #9
0
        public HttpResponseMessage DoCreate(LevelEntity Level)
        {
            if (!string.IsNullOrEmpty(Level.Name) && !string.IsNullOrEmpty(Level.Describe) && !string.IsNullOrEmpty(Level.Url))
            {
                var levelModel = new LevelEntity
                {
                    Name     = Level.Name,
                    Describe = Level.Describe,
                    Url      = Level.Url,
                    Uptime   = DateTime.Now,
                    Addtime  = DateTime.Now,
                };

                try
                {
                    if (_levelService.Create(levelModel) != null)
                    {
                        return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!")));
                    }
                }
                catch
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")));
                }
            }
            return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")));
        }
Exemple #10
0
    public void registerVitalEntity(LevelEntity entity)
    {
        entities.Add(entity.gameObject);

        vitalEntities++;

        entity.isVital = true;
    }
Exemple #11
0
        /// <summary>
        /// Creates a new LevelButton.
        /// </summary>
        /// <param name="level">The level to associate with the button.</param>
        public LevelButton(LevelEntity level)
        {
            _LevelText = new TextEntity(GameHandler.AssetHandler.GetSpriteFont("Fonts/Hud"));
            AddChild(_LevelText);

            ClickedSoundEffect = GameHandler.AssetHandler.GetSoundEffect("Sounds/snd_player_won");

            Level = level;
        }
Exemple #12
0
        private void TrySetEntityToSpawn(LevelEntity entity)
        {
            if (LevelController == null)
            {
                return;
            }

            Selection.activeGameObject    = LevelController.gameObject;
            LevelController.EntityToSpawn = entity;
        }
        public async Task <IActionResult> Create([Bind("Name,Id")] LevelEntity levelEntity)
        {
            if (ModelState.IsValid)
            {
                await _levelRepository.AddAsync(levelEntity);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(levelEntity));
        }
Exemple #14
0
 public LevelEntity Update(LevelEntity entity)
 {
     try
     {
         _levelRepository.Update(entity);
         return(entity);
     }
     catch (Exception e)
     {
         _log.Error(e, "数据库操作出错");
         return(null);
     }
 }
Exemple #15
0
 public bool Delete(LevelEntity entity)
 {
     try
     {
         _levelRepository.Delete(entity);
         return(true);
     }
     catch (Exception e)
     {
         _log.Error(e, "数据库操作出错");
         return(false);
     }
 }
Exemple #16
0
    /// <summary>
    /// Load all the assets that the session needs but it doesn't start the Session.
    /// </summary>
    public void LoadSession()
    {
        m_levelEntity = GameObject.Instantiate <LevelEntity>(m_level.Data.LevelEntity);
        m_levelEntity.transform.position = Vector3.zero;

        m_mainCharacter.CreateEntity(m_levelEntity.StartingPoint.SpawnPosition.position);
        m_inputListener = CreateListener();
        m_collectibles  = new List <CollectableItem>(m_levelEntity.Items);

        CameraManager.Instance.ResetCameraPosition();

        InstantiateEnemies();
    }
Exemple #17
0
 protected void SendPolymorph(MonoBehaviour m, bool heated)
 {
     if (!StatMaster.isLocalSim)
     {
         LevelEntity le = m.GetComponent <LevelEntity>();
         if (le == null)
         {
             return;
         }
         Entity  e             = Entity.From(le);
         Message targetMessage = polymorphMessageType.CreateMessage(Block.From(poultryizer), e, heated);
         ModNetworking.SendToAll(targetMessage);
     }
 }
Exemple #18
0
    public void Init(LevelEntity entity)
    {
        CurrentProbCount  = entity.CurrentProbCount;
        ExpectedProbCount = entity.ExpectedProbCount;
        LevelIndex        = entity.LevelIndex;

        foreach (var probEntity in entity.ActiveProbs)
        {
            var probGo = GameManager.Instance.Pooler.Get(probEntity.ProbType, probEntity.Position, Quaternion.identity);
            var prob   = probGo.GetComponent <Probs>();
            ActiveProbs.Add(prob);
            prob.Init(probEntity.Velocity, probEntity.AngularVelocity);
        }
    }
        /// <summary>
        /// Converts the <see cref="Level"/> domain model into a <see cref="LevelEntity"/> data object.
        /// </summary>
        /// <returns>The <see cref="LevelEntity"/> data object.</returns>
        /// <param name="level">The <see cref="Level"/> domain model.</param>
        internal static LevelEntity ToEntity(this Level level)
        {
            LevelEntity levelEntity = new LevelEntity
            {
                Id               = level.Id,
                Name             = level.Name,
                Description      = level.Description,
                BackgroundColour = level.BackgroundColour.ToHexadecimal(),
                Terrain          = new List <TerrainInstanceEntity>(),
                WorldObjects     = new List <WorldObjectInstanceEntity>()
            };

            for (int y = 0; y < level.Size.Height; y++)
            {
                for (int x = 0; x < level.Size.Width; x++)
                {
                    if (level.Tiles[x, y] == null)
                    {
                        continue;
                    }

                    if (level.Tiles[x, y].HasTerrain)
                    {
                        TerrainInstanceEntity terrainInstanceEntity = new TerrainInstanceEntity
                        {
                            TerrainId = level.Tiles[x, y].TerrainId,
                            LocationX = x,
                            LocationY = y
                        };

                        levelEntity.Terrain.Add(terrainInstanceEntity);
                    }

                    if (level.Tiles[x, y].HasWorldObject)
                    {
                        WorldObjectInstanceEntity worldObjectInstanceEntity = new WorldObjectInstanceEntity
                        {
                            WorldObjectId = level.Tiles[x, y].WorldObjectId,
                            LocationX     = x,
                            LocationY     = y
                        };

                        levelEntity.WorldObjects.Add(worldObjectInstanceEntity);
                    }
                }
            }

            return(levelEntity);
        }
Exemple #20
0
    void LookForPlayers()
    {
        // GameObject player = GameObject.Find("Player");

        target          = playerEntity;
        targetTransform = playerTransform;
        return;

        // float playerDistance = Vector3.Distance(transform.position, player.transform.position);

        // RaycastHit raycastinfo;
        // Ray checkRay = new Ray(transform.position, (player.transform.position - transform.position).normalized);

        // if (!Physics.Raycast(checkRay, out raycastinfo, playerDistance * 0.95f)) {
        //  target = player;
        // }
    }
Exemple #21
0
    public static LevelEntity SpawnEntity(Vector3 position, float direction, MultigenObject mobj, WadFile wad)
    {
        GameObject newObj = new GameObject(mobj.name);

        newObj.transform.localPosition = position;


        LevelEntity ent = newObj.AddComponent <LevelEntity>();

        ent.spriteTransform = new GameObject("Sprite").transform;
        ent.spriteTransform.SetParent(newObj.transform, false);
        ent.spriteTransform.localScale = new Vector3(1.6f, 1.76f, 1.6f);
        ent.LoadMultigen(mobj, wad);
        ent.direction = direction;

        return(ent);
    }
Exemple #22
0
        public new void FinalKillTeams(PlayerCorpse corpse, Allegiance otherSpotlightTeam)
        {
            List <LevelEntity> list = new List <LevelEntity> ();

            for (int i = 0; i < 8; i++)
            {
                if (TFGame.Players [i] && this.Session.MatchSettings.Teams [i] == otherSpotlightTeam)
                {
                    this.Session.MatchStats [i].GotWin = true;
                    LevelEntity playerOrCorpse = this.Session.CurrentLevel.GetPlayerOrCorpse(i);
                    if (playerOrCorpse != null && playerOrCorpse != corpse)
                    {
                        list.Add(playerOrCorpse);
                    }
                }
            }
            this.Session.CurrentLevel.LightingLayer.SetSpotlight(list.ToArray());
            this.FinalKillNoSpotlight();
        }
 public LevelDTO GetLevelName(int LevelID)
 {
     using (MyDbContext dbc = new MyDbContext())
     {
         CommonService <LevelEntity> cs = new CommonService <LevelEntity>(dbc);
         LevelEntity model = cs.GetAll().Where(r => r.LevelID == LevelID).SingleOrDefault();
         if (model != null)
         {
             return(new LevelDTO
             {
                 LevelID = model.LevelID,
                 LevelName = model.LevelName
             });
         }
         else
         {
             return(null);
         }
     }
 }
Exemple #24
0
        public static Arrow Create(ArrowTypes type, LevelEntity owner, Vector2 position, float direction, int?overrideCharacterIndex = null, int?overridePlayerIndex = null)
        {
            patch_Arrow arrow;

            if ((int)type > 10)
            {
                // custom arrow
                Type ctype = ModArrow.ModArrowTypes[(int)type];
                arrow = (patch_Arrow)ctype.GetConstructor(ModLoader.mm.ModLoader._EmptyTypeArray).Invoke(ModLoader.mm.ModLoader._EmptyObjectArray);
                arrow.OverrideCharacterIndex = overrideCharacterIndex;
                arrow.OverridePlayerIndex    = overridePlayerIndex;
                arrow.Init(owner, position, direction);
            }
            else
            {
                // vanilla arrow
                return(orig_Create(type, owner, position, direction, overrideCharacterIndex, overridePlayerIndex));
            }
            return(arrow);
        }
Exemple #25
0
    public void BuildLevelEntities(MultigenParser multigen)
    {
        for (int i = 0; i < map.things.Length; i++)
        {
            if (!map.things[i].multiplayer)
            {
                MultigenObject mobj = multigen.GetObjectByDoomedNum(map.things[i].type);
                if (mobj != null && thingSectors.ContainsKey(i))
                {
                    GameObject newObj = new GameObject(mobj.name);
                    newObj.transform.localPosition = new Vector3(map.things[i].x * SCALE, thingSectors[i].floorHeight * SCALE * 1.2f, map.things[i].y * SCALE);
                    newObj.transform.localScale    = new Vector3(1.6f, 1.76f, 1.6f);
                    newObj.transform.parent        = thingsObject.transform;

                    LevelEntity ent = newObj.AddComponent <LevelEntity>();

                    ent.LoadMultigen(multigen, mobj, wad);
                    ent.direction = (float)map.things[i].angle;
                }
            }
        }
    }
Exemple #26
0
    void getLevels(object obj)
    {
        try
        {
            Action <DBCallback>           callback  = (Action <DBCallback>)obj;
            Dictionary <int, LevelEntity> levels    = new Dictionary <int, LevelEntity> ();
            IEnumerable <LevelTable>      dataTable = connection.Table <LevelTable>();
            foreach (LevelTable item in dataTable)
            {
                LevelEntity levelEntity   = new LevelEntity();
                string      levelDecrypt  = Encryption.Decrypt(item.Level);
                string      scoreDecrypt  = Encryption.Decrypt(item.Score);
                string      rateDecrypt   = Encryption.Decrypt(item.Rate);
                string      replayDecrypt = Encryption.Decrypt(item.Replay);

                try {
                    levelEntity.Level  = Convert.ToInt32(levelDecrypt);
                    levelEntity.Score  = Convert.ToInt32(scoreDecrypt);
                    levelEntity.Rate   = Convert.ToInt32(rateDecrypt);
                    levelEntity.Replay = Convert.ToInt32(replayDecrypt);

                    // Add Score Entity to Score List
                    levels[levelEntity.Level] = levelEntity;
                } catch (Exception ex) {
                    Debug.LogException(ex);
                }
            }
            Debug.LogWarning("getLevels");
            DBCallback dbCallback = new DBCallback();
            dbCallback.Data = levels;
            dbCallback.completedCallback = callback;
            DBCallbackDispatcher.Singleton.requests.Enqueue(dbCallback);
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Exemple #27
0
        /// <summary>
        /// Creates a new PlayingState.
        /// </summary>
        public PlayingState()
            : base("playing")
        {
            TextureEntity background = new TextureEntity();
            background.Texture = GameHandler.AssetHandler.GetTexture("Backgrounds/spr_sky");
            AddChild(background);
            Size = new Vector2(GameHandler.GraphicsHandler.Resolution.X, GameHandler.GraphicsHandler.Resolution.Y);
            background.Size = Size;

            // Load levels
            for (int i = 1; i <= GameHandler.AssetHandler.CountFiles("Levels") - 1; i++) {
                LevelEntity level = new LevelEntity(i);
                level.Active = false;
                level.Visible = false;
                AddChild(level);
            }

            // Add quit button
            QuitButton quitButton = new QuitButton();
            quitButton.Position = new Vector2(Size.X - quitButton.Size.X - 10, 10);
            AddChild(quitButton);

            // Game over
            _Overlay = new TextureEntity();
            _Overlay.Visible = false;
            AddChild(_Overlay);

            // Show timer
            Timer = new TimerEntity();
            Timer.Position = new Vector2(25, 30);
            AddChild(Timer);

            // Show hint
            Hint = new HintEntity();
            Hint.Position = new Vector2((Size.X - Hint.Size.X) / 2, 10);
            AddChild(Hint);
        }
Exemple #28
0
        public HttpResponseMessage DoEdit([FromBody] LevelEntity Level)
        {
            if (Level != null && !string.IsNullOrEmpty(Level.Id.ToString()) && PageHelper.ValidateNumber(Level.Id.ToString()) && !string.IsNullOrEmpty(Level.Name) && !string.IsNullOrEmpty(Level.Describe) && !string.IsNullOrEmpty(Level.Url))
            {
                var levelModel = _levelService.GetLevelById(Level.Id);
                levelModel.Uptime   = DateTime.Now;
                levelModel.Name     = Level.Name;
                levelModel.Describe = Level.Describe;
                levelModel.Url      = Level.Url;

                try
                {
                    if (_levelService.Update(levelModel) != null)
                    {
                        return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据更新成功!")));
                    }
                }
                catch
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据更新失败!")));
                }
            }
            return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")));
        }
Exemple #29
0
    void SpawnMissile(Vector3 target, string thingType)
    {
        MultigenObject mobj = wad.multigen.objects[thingType];

        LevelEntity thing = SpawnEntity(
            transform.position + Vector3.up * 0.75f * height,
            0f,
            mobj,
            wad
            );

        if (thing.seeSound != null)
        {
            thing.PlaySound(thing.seeSound, false);
        }

        thing.target = this;
        float direction = Mathf.Atan2(target.z - transform.position.z, target.x - transform.position.x) * Mathf.Rad2Deg;

        // TODO: fuzzy player angle variant

        thing.direction = direction;
        thing.move      = (target - thing.transform.position).normalized;
    }
Exemple #30
0
    private float?canMove(Vector3 origin, Vector3 destination, char shape)
    {
        if (destination.x < 0 || destination.y < 0 || destination.z < 0)
        {
            return(null);
        }

        LevelEntity destinationTile = levelLayout[(int)destination.x, (int)destination.y, (int)destination.z];

        if (destinationTile == null)
        {
            return(null);
        }

        LevelEntity originTile = levelLayout[(int)origin.x, (int)origin.y, (int)origin.z];

        if (originTile.getShape() == MyDictionary.PLATFORM_STAIRS && destinationTile.getShape() == MyDictionary.PLATFORM_LOW)
        {
            return(null);
        }

        if ((originTile.getShape() == MyDictionary.PLATFORM_HIGH && destinationTile.getShape() == MyDictionary.PLATFORM_LOW) ||
            (originTile.getShape() == MyDictionary.PLATFORM_LOW && destinationTile.getShape() == MyDictionary.PLATFORM_HIGH) ||
            (originTile.getShape() == MyDictionary.PLATFORM_START && destinationTile.getShape() == MyDictionary.PLATFORM_HIGH) ||
            (destinationTile.getShape() == MyDictionary.PLATFORM_END && destinationTile.getShape() == MyDictionary.PLATFORM_HIGH))
        {
            return(null);
        }

        if (character.getShape() != MyDictionary.SHAPE_SPHERE && originTile.getShape() == MyDictionary.PLATFORM_RAMP)
        {
            return(null);
        }

        Vector3 directionVector = destination - origin;
        int     direction;

        if (directionVector.x < -0.5f)
        {
            direction = MyDictionary.ENTRANCE_RIGHT;
        }
        else if (directionVector.x > 0.5f)
        {
            direction = MyDictionary.ENTRANCE_LEFT;
        }
        else if (directionVector.z < -0.5f)
        {
            direction = MyDictionary.ENTRANCE_UP;
        }
        else if (directionVector.z > 0.5f)
        {
            direction = MyDictionary.ENTRANCE_DOWN;
        }
        else
        {
            return(null);
        }

        if (destinationTile.canBeWalkedBy(shape) && destinationTile.canEnterFrom(direction))
        {
            return(destinationTile.getPlacementHeight());
        }
        return(null);
    }
 /// <summary>
 /// Create a new LevelEntity object.
 /// </summary>
 /// <param name="id">Initial value of Id.</param>
 /// <param name="name">Initial value of Name.</param>
 /// <param name="description">Initial value of Description.</param>
 /// <param name="colorValue">Initial value of ColorValue.</param>
 /// <param name="escalationTimeout">Initial value of EscalationTimeout.</param>
 /// <param name="shortDescription">Initial value of ShortDescription.</param>
 /// <param name="uuid">Initial value of Uuid.</param>
 /// <param name="directContactRequired">Initial value of DirectContactRequired.</param>
 /// <param name="dueTimeout">Initial value of DueTimeout.</param>
 public static LevelEntity CreateLevelEntity(int id, string name, string description, string colorValue, global::System.DateTime escalationTimeout, string shortDescription, global::System.Guid uuid, bool directContactRequired, global::System.DateTime dueTimeout)
 {
     LevelEntity levelEntity = new LevelEntity();
     levelEntity.Id = id;
     levelEntity.Name = name;
     levelEntity.Description = description;
     levelEntity.ColorValue = colorValue;
     levelEntity.EscalationTimeout = escalationTimeout;
     levelEntity.ShortDescription = shortDescription;
     levelEntity.Uuid = uuid;
     levelEntity.DirectContactRequired = directContactRequired;
     levelEntity.DueTimeout = dueTimeout;
     return levelEntity;
 }
 /// <summary>
 /// There are no comments for LevelEntitySet in the schema.
 /// </summary>
 public void AddToLevelEntitySet(LevelEntity levelEntity)
 {
     base.AddObject("LevelEntitySet", levelEntity);
 }
Exemple #33
0
	void getLevels (object obj)
	{
		try
		{
			Action<DBCallback> callback = (Action<DBCallback>)obj;
			Dictionary<int, LevelEntity> levels = new Dictionary<int, LevelEntity> ();
			IEnumerable<LevelTable> dataTable = connection.Table<LevelTable>();
			foreach (LevelTable item in dataTable)
			{
				LevelEntity levelEntity = new LevelEntity ();				
				string levelDecrypt = Encryption.Decrypt (item.Level);
				string scoreDecrypt = Encryption.Decrypt (item.Score);
				string rateDecrypt = Encryption.Decrypt (item.Rate);
				string replayDecrypt = Encryption.Decrypt (item.Replay);

				try {
					levelEntity.Level = Convert.ToInt32 (levelDecrypt);
					levelEntity.Score = Convert.ToInt32 (scoreDecrypt);
					levelEntity.Rate = Convert.ToInt32 (rateDecrypt);
					levelEntity.Replay = Convert.ToInt32 (replayDecrypt);
					
					// Add Score Entity to Score List
					levels[levelEntity.Level] = levelEntity;
				} catch (Exception ex) {
					Debug.LogException (ex);
				}
			}
			Debug.LogWarning("getLevels");
			DBCallback dbCallback = new DBCallback ();
			dbCallback.Data = levels;
			dbCallback.completedCallback = callback;
			DBCallbackDispatcher.Singleton.requests.Enqueue (dbCallback);
		}
		catch(Exception ex)
		{
			Debug.LogException (ex);
		}
	}
        public HttpResponseMessage AddBroker([FromBody] BrokerModel brokerModel)
        {
            var validMsg = "";

            if (!brokerModel.ValidateModel(out validMsg))
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误,请重新输入")));
            }

            #region 验证码判断 解密
            var      strDes = EncrypHelper.Decrypt(brokerModel.Hidm, "Hos2xNLrgfaYFY2MKuFf3g==");//解密
            string[] str    = strDes.Split('$');
            if (str.Count() < 2)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "验证码错误,请重新发送!")));
            }
            string   source  = str[0];                                              //获取验证码和手机号
            DateTime date    = Convert.ToDateTime(str[1]);                          //获取发送验证码的时间
            DateTime dateNow = Convert.ToDateTime(DateTime.Now.ToLongTimeString()); //获取当前时间
            TimeSpan ts      = dateNow.Subtract(date);
            double   secMinu = ts.TotalMinutes;                                     //得到发送时间与现在时间的时间间隔分钟数
            if (secMinu > 3)                                                        //发送时间与接受时间是否大于3分钟
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "你已超过时间验证,请重新发送验证码!")));
            }
            else
            {
                // source.Split('#')[0] 验证码
                // source.Split('#')[1] 手机号
                if (brokerModel.Phone != source.Split('#')[1])//判断手机号是否一致
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "验证码错误,请重新发送!")));
                }

                if (brokerModel.MobileYzm != source.Split('#')[0])//判断验证码是否一致
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "验证码错误,请重新发送!")));
                }
            }

            #endregion

            #region 判断两次密码是否一致
            if (brokerModel.Password != brokerModel.SecondPassword)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "手机号不能为空")));
            }
            #endregion

            #region 判断邀请码是否存在真实  (brokerInfoController 中GetBrokerByInvitationCode方法也同一判断)
            MessageDetailEntity messageDetail = null;
            if (!string.IsNullOrEmpty(brokerModel.inviteCode))
            {
                MessageDetailSearchCondition messageSearchcondition = new MessageDetailSearchCondition
                {
                    InvitationCode = brokerModel.inviteCode,
                    Title          = "推荐经纪人"
                };
                messageDetail = _MessageService.GetMessageDetailsByCondition(messageSearchcondition).FirstOrDefault();//判断邀请码是否存在
                if (messageDetail == null)
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "邀请码错误!")));
                }
            }
            #endregion


            #region UC用户创建 杨定鹏 2015年5月28日14:52:48
            var user = _userService.GetUserByName(brokerModel.UserName);
            if (user != null)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "用户名已经存在")));
            }


            var condition = new BrokerSearchCondition
            {
                OrderBy = EnumBrokerSearchOrderBy.OrderById,
                State   = 1,
                Phone   = brokerModel.Phone
            };

            //判断user表和Broker表中是否存在用户名
            int user2 = _brokerService.GetBrokerCount(condition);

            if (user2 != 0)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "手机号已经存在")));
            }

            var brokerRole = _roleService.GetRoleByName("user");

            //User权限缺少时自动添加
            if (brokerRole == null)
            {
                brokerRole = new Role
                {
                    RoleName        = "user",
                    RolePermissions = null,
                    Status          = RoleStatus.Normal,
                    Description     = "刚注册的用户默认归为普通用户user"
                };
            }

            var newUser = new UserBase
            {
                UserName       = brokerModel.UserName,
                Password       = brokerModel.Password,
                RegTime        = DateTime.Now,
                NormalizedName = brokerModel.UserName.ToLower(),
                //注册用户添加权限
                UserRoles = new List <UserRole>()
                {
                    new UserRole()
                    {
                        Role = brokerRole
                    }
                },
                Status = 0
            };

            PasswordHelper.SetPasswordHashed(newUser, brokerModel.Password);

            #endregion

            #region Broker用户创建 杨定鹏 2015年5月28日14:53:32

            var model = new BrokerEntity();
            model.UserId      = _userService.InsertUser(newUser).Id;
            model.Brokername  = brokerModel.Phone;
            model.Nickname    = brokerModel.Nickname;
            model.Phone       = brokerModel.Phone;
            model.Totalpoints = 0;
            model.Amount      = 0;
            model.Usertype    = EnumUserType.普通用户;
            model.Regtime     = DateTime.Now;
            model.State       = 1;
            model.Adduser     = 0;
            model.Addtime     = DateTime.Now;
            model.Upuser      = 0;
            model.Uptime      = DateTime.Now;

            //判断初始等级是否存在,否则创建
            var level = _levelService.GetLevelsByCondition(new LevelSearchCondition {
                Name = "默认等级"
            }).FirstOrDefault();
            if (level == null)
            {
                var levelModel = new LevelEntity
                {
                    Name     = "默认等级",
                    Describe = "系统默认初始创建",
                    Url      = "",
                    Uptime   = DateTime.Now,
                    Addtime  = DateTime.Now,
                };
                _levelService.Create(levelModel);
            }

            model.Level = level;

            var newBroker = _brokerService.Create(model);



            #endregion

            #region 推荐经纪人
            if (!string.IsNullOrEmpty(brokerModel.inviteCode))
            {
                //添加经纪人
                var entity = new RecommendAgentEntity
                {
                    PresenteebId = newBroker.Id,
                    Qq           = newBroker.Qq.ToString(),
                    Agentlevel   = newBroker.Agentlevel,
                    Brokername   = newBroker.Brokername,
                    Phone        = newBroker.Phone,
                    Regtime      = DateTime.Now,
                    Broker       = _brokerService.GetBrokerById(Convert.ToInt32(messageDetail.InvitationId)),
                    Uptime       = DateTime.Now,
                    Addtime      = DateTime.Now,
                };

                _recommendagentService.Create(entity);
            }
            #endregion

            return(PageHelper.toJson(PageHelper.ReturnValue(true, "注册成功")));
        }
Exemple #35
0
 public static extern Arrow orig_Create(ArrowTypes type, LevelEntity owner, Vector2 position, float direction, int?overrideCharacterIndex = null, int?overridePlayerIndex = null);
Exemple #36
0
        private void InitializeEntities()
        {
            LevelEntity oldLady = new LevelEntity();
            oldLady.AddComponent(new EntitySprite(new List<Texture2D> { _content.Load<Texture2D>("Level2-OldLady") }, 94, 133, new Vector2(420,506), 0.6666, 0.6f));
            oldLady.AddComponent(new EntityAnimation(94,133));
            oldLady.EntityName = LevelEntityName.OldLady;
            _entities.Add(oldLady);

            LevelEntity blob = new LevelEntity();
            blob.AddComponent(new EntitySprite(new List<Texture2D> { _content.Load<Texture2D>("Level2-Blob") }, 50, 77, new Vector2(872,322), 0.6666, 0.05f));
            //blob.AddComponent(new EntityAnimation(50, 77, LevelEntityName.Blob));
            blob.AddComponent(new EntityRotation(new Vector2(26.5f,10), 0.25f));
            blob.EntityName = LevelEntityName.Blob;
            _entities.Add(blob);

            LevelEntity water = new LevelEntity();
            water.AddComponent(new EntitySprite(new List<Texture2D> { _content.Load<Texture2D>("Level2-Water2") }, 30, 107, new Vector2(680, 495), 0.6666, 0.77f));
            water.AddComponent(new EntityAnimation(30, 107));
            water.EntityName = LevelEntityName.Water;
            _entities.Add(water);
        }