public override void ApplyEvent(GameWorldController gameWorldController, GameEvent.OnEventCompleteDelegate onComplete)
    {
        GameData currentGame = gameWorldController.Model.CurrentGame;

        if (currentGame.CharacterID != _characterState.character_id)
        {
            base.ApplyEvent(gameWorldController, onComplete);

            // Add the character state to the current game state
            currentGame.SetCharacterById(_characterState.character_id, _characterState);

            // Create a new character entity using the character data just set in the game state
            {
                CharacterEntity characterEntity = new CharacterEntity(_characterState.character_id);

                characterEntity.AddToGameWorld(gameWorldController);
            }
        }
        else
        {
            Debug.Log("Ignoring apply CharacterJoinedGame event for primary character_id=" + _characterState.character_id);
        }

        // Completes immediately
        if (onComplete != null)
        {
            onComplete();
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            character = new CharacterEntity(GraphicsDevice, "Content/miku.png");
            character.Position = Vector2.Zero;

            base.Initialize ();
        }
 public override void ReactOnCollision(CharacterEntity character)
 {
     Task task = Task.Run(() => { Console.Beep(1500, 500); });
     if (character.livesLeft++ > 3)
     {
         character.livesLeft = 3;
     }
     else
     {
         character.livesLeft++;
     }         
 }
    public AsyncCharacterMoveRequest(GameObject requestOwnerObject, CharacterEntity entity, Point3d target)
    {
        // Remember where we came from in case the server rejects our predictive movement request
        CharacterData characterData = entity.MyCharacterData;

        OriginalPosition = new Point3d(characterData.x, characterData.y, characterData.z);
        OriginalFacingAngle = characterData.angle;
        TargetPosition = new Point3d(target);
        TagetFacingAngle = OriginalFacingAngle;

        m_entity = entity;
        m_requestOwnerObject = requestOwnerObject;

        Status = eRequestStatus.preflight;
        ResultCode = eResult.none;
        ResultDetails = "";
        ServerResponse = null;
    }
    public AsyncDrainEnergyTankRequest(
        GameObject requestOwnerObject, 
        CharacterEntity entity,
        Point3d entryPoint, 
        EnergyTankData energyTank)
    {
        // Remember where we came from in case the server rejects our predictive movement request
        CharacterData characterData = entity.MyCharacterData;

        OriginalPosition = new Point3d(characterData.x, characterData.y, characterData.z);
        TargetEnergyTank = energyTank;
        EnergyTankApproachPoint = entryPoint;

        m_entity = entity;
        m_requestOwnerObject = requestOwnerObject;

        Status = eRequestStatus.preflight;
        ResultCode = eResult.none;
        ResultDetails = "";
        ServerResponse = null;
    }
    public AsyncCharacterPortalRequest(
        GameObject requestOwnerObject, 
        CharacterEntity entity,
        Point3d entryPoint, 
        RoomPortal portal)
    {
        // Remember where we came from in case the server rejects our predictive movement request
        CharacterData characterData = entity.MyCharacterData;

        OriginalPosition = new Point3d(characterData.x, characterData.y, characterData.z);
        OriginalFacingAngle = characterData.angle;
        OriginalRoomKey = characterData.CurrentRoomKey;
        OriginPortal = portal;
        OriginPortalEntryPoint = entryPoint;

        m_entity = entity;
        m_requestOwnerObject = requestOwnerObject;

        Status = eRequestStatus.preflight;
        ResultCode = eResult.none;
        ResultDetails = "";
        ServerResponse = null;
    }
Exemplo n.º 7
0
 public override bool CanRespawn(CharacterEntity character)
 {
     return(false);
 }
Exemplo n.º 8
0
    public void OnRoomLoaded(RoomKey roomKey)
    {
        RoomData currentRoom = m_gameWorldModel.GetRoomData(roomKey);

        // Get a list of all the characters that are in the same room as my character
        List<int> characterIDList = m_gameWorldModel.GetCharacterIDListInRoom(roomKey);

        // Remove any existing character
        List<int> allCharacterIds = new List<int>(m_gameWorldModel.GetCharacterEntityMap().Keys);
        foreach (int characterEntityId in allCharacterIds)
        {
            CharacterEntity characterEntity= m_gameWorldModel.GetCharacterEntity(characterEntityId);

            characterEntity.RemoveFromGameWorld(this);
        }

        // (Re)Create character entities for each character in the room
        foreach (int characterID in characterIDList)
        {
            CharacterEntity newCharacterEntity = new CharacterEntity(characterID);

            newCharacterEntity.AddToGameWorld(this);
        }

        // Remove any existing mobs
        List<int> allMobIds = new List<int>(m_gameWorldModel.GetMobEntityMap().Keys);
        foreach (int mobEntityId in allMobIds)
        {
            MobEntity mobEntity = m_gameWorldModel.GetMobEntity(mobEntityId);

            mobEntity.RemoveFromGameWorld(this);
        }

        // (Re)Create mob entities for each mob in the room
        foreach (MobData mobData in currentRoom.MobMap.Values)
        {
            MobEntity newMobEntity = new MobEntity(mobData.mob_id);

            newMobEntity.AddToGameWorld(this);
        }

        // Remove any existing energy tanks
        List<int> allEnergyTankIds = new List<int>(m_gameWorldModel.GetEnergyTankEntityMap().Keys);
        foreach (int energyTankId in allEnergyTankIds)
        {
            EnergyTankEntity energyTankEntity = m_gameWorldModel.GetEnergyTankEntity(energyTankId);

            energyTankEntity.RemoveFromGameWorld(this);
        }

        // (Re)Create energy tank entities for each energy tank in the room
        foreach (EnergyTankData energyTankData in currentRoom.EnergyTankMap.Values)
        {
            EnergyTankEntity newEnergyTankEntity = new EnergyTankEntity(energyTankData.energy_tank_id);

            newEnergyTankEntity.AddToGameWorld(this);
        }

        // generate all of the terrain tiles and static objects in the room
        gameWorldView.RebuildRoom(currentRoom);

        // Notify the overlay of a room reload
        m_contextOverlayController.OnRoomLoaded(currentRoom);
    }
Exemplo n.º 9
0
 public virtual void UseItem(CharacterEntity characterEntity)
 {
     Alt.Log($"[ITEM] {characterEntity.DbModel.Name} {characterEntity.DbModel.Surname} użył item ID: {Id} nazwa: {Name}");
 }
Exemplo n.º 10
0
 public virtual void UseItem(CharacterEntity character)
 {
     //TODO Pomysł, można tutaj dopisywać wszystkie logi używania przedmiotów
 }
Exemplo n.º 11
0
 public static void GiveDrivingLicense(CharacterEntity getter)
 {
     getter.DbModel.HasDrivingLicense = true;
     getter.Save();
 }
Exemplo n.º 12
0
 protected Event(Guid id, Name name, Description description, CharacterEntity source) : base(id, name, description)
 {
     Source = source;
 }
 private void Start()
 {
     numberOfDefendersInGame++;
     instances.Add(this);
     character = GetComponent <CharacterEntity>();
 }
Exemplo n.º 14
0
        /// <summary>
        /// Picks up this <see cref="Entity"/>.
        /// </summary>
        /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to pick up this <see cref="Entity"/>.</param>
        /// <returns>True if this <see cref="Entity"/> was successfully picked up, else false.</returns>
        public override bool Pickup(CharacterEntity charEntity)
        {
            // Check for invalid character
            if (charEntity == null)
            {
                const string errmsg = "Null charEntity specified.";
                if (log.IsWarnEnabled)
                    log.Warn(errmsg);
                Debug.Fail(errmsg);
                return false;
            }

            // Check if the ItemEntity can be picked up
            if (!CanPickup(charEntity))
                return false;

            // Convert to a character
            var character = charEntity as Character;
            if (character == null)
            {
                const string errmsg =
                    "Unable to convert CharacterEntity `{0}` to Character for some reason. " +
                    "Is there another type, besides Character, inheriting CharacterEntity?";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, charEntity);
                Debug.Fail(string.Format(errmsg, charEntity));
                return false;
            }

            // Create a deep copy of the item to give to the character instead of giving them this item (its easier this way)
            var itemCopy = (ItemEntity)DeepCopy();
            var amountGiven = character.GiveItem(itemCopy);

            // If nothing was given, then nothing happens... move on
            if (amountGiven <= 0)
            {
                Debug.Assert(amountGiven == 0);
                return false;
            }

            // Find the new item amount
            var newAmount = (byte)Math.Max(Math.Min(Amount - amountGiven, byte.MaxValue), byte.MinValue);
            Debug.Assert(amountGiven > 0 && amountGiven <= Amount);

            // Update the amount property
            Amount = newAmount;

            // If all of the item was picked up, then destroy this item
            if (newAmount == 0)
                Destroy();

            // Notify listeners using the item copy since that was the one actually given to them
            if (PickedUp != null)
                PickedUp.Raise(itemCopy, EventArgsHelper.Create(charEntity));

            return true;
        }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="grades"></param>
 public bool StartMonsterFight(CharacterEntity character, IEnumerable <MonsterGradeDAO> grades)
 {
     return(FightManager.StartMonsterFight(character, new MonsterGroupEntity(NextMonsterId, Id, RandomFreeCell, grades)));
 }
Exemplo n.º 16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="cellId"></param>
 /// <param name="monsters"></param>
 /// <returns></returns>
 public bool CanBeAggro(CharacterEntity character, int cellId, MonsterGroupEntity monsters)
 {
     return(Pathfinding.GoalDistance(this, cellId, monsters.CellId) <= monsters.AggressionRange &&
            ((character.AlignmentId == (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL && monsters.AlignmentId == -1) ||
             (character.AlignmentId != (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL && monsters.AlignmentId != character.AlignmentId)));
 }
Exemplo n.º 17
0
 public CustomBody(CharacterEntity self)
 {
     this.self = self;
 }
Exemplo n.º 18
0
    public AttackInfo ReceiveDamage(CharacterEntity attacker, int pAtk, int mAtk, int acc, float critChance, float critDamageRate, int hitCount = 1, int fixDamage = 0)
    {
        lastAttacker = attacker;
        AttackInfo attackInfo = new AttackInfo();

        attackInfo.lastHP = self.Hp;
        if (hitCount <= 0)
        {
            hitCount = 1;
        }
        var attributes = self.GetTotalAttributes();
        var isCritical = false;
        var isBlock    = false;
        var totalDmg   = FormulaUtils.FightFormula(pAtk, mAtk, acc, critChance, critDamageRate, attributes, hitCount, fixDamage);

        // Critical occurs
        if (Random.value <= critChance)
        {
            totalDmg         = Mathf.CeilToInt(totalDmg * critDamageRate);
            isCritical       = true;
            attackInfo.baoji = true;
            self.ApplySkillAndBuff(CustomSkill.TriggerType.gobaoji);
        }
        // Block occurs
        if (Random.value <= attributes.exp_blockChance)
        {
            totalDmg          = Mathf.CeilToInt(totalDmg / attributes.exp_blockDamageRate);
            isBlock           = true;
            attackInfo.gedang = true;
            self.ApplySkillAndBuff(CustomSkill.TriggerType.gogedang);
        }

        var hitChance = 0f;

        if (acc > 0)
        {
            hitChance = acc / attributes.eva;
        }

        // Cannot evade, receive damage
        if (hitChance < 0 || Random.value > hitChance)
        {
            attackInfo.shanbi = true;
            DeductBlood((int)totalDmg, DmgType.Miss);
            self.ApplySkillAndBuff(CustomSkill.TriggerType.gomiss);
        }
        else
        {
            if (isBlock)
            {
                DeductBlood((int)totalDmg, DmgType.Block);
            }
            else if (isCritical)
            {
                DeductBlood((int)totalDmg, DmgType.Critical);
            }
            else
            {
                DeductBlood((int)totalDmg, DmgType.Normal);
            }
        }
        attackInfo.totalDamage = (int)totalDmg;
        if (self.Hp <= 0)
        {
            attackInfo.die = true;
        }
        self.ApplySkillAndBuff(CustomSkill.TriggerType.receiveDamage);
        // Play hurt animation
        //CacheAnimator.ResetTrigger(ANIM_KEY_HURT);
        //CacheAnimator.SetTrigger(ANIM_KEY_HURT);
        AnimReceiveDamage();
        FriensReceiveDamage();
        return(attackInfo);
    }
Exemplo n.º 19
0
        //TODO: Dorobić, że osoba zarządzająca grupą może akceptować oferte tuningu pojazdu
        public override void UseItem(CharacterEntity characterEntity)
        {
            IPlayer     player = characterEntity.AccountEntity.Player;
            GroupEntity group  = characterEntity.OnDutyGroup;

            if (group == null)
            {
                player.SendChatMessageInfo("Nie masz uprawnień, aby montować części w samochodzie");
                return;
            }


            if (group.DbModel.GroupType != GroupType.Mechanic || ((Mechanic)group).CanPlayerTuningVehicle(characterEntity.AccountEntity))
            {
                if (DbModel.VehicleUpgradeId == null)
                {
                    if (player.Vehicle == null)
                    {
                        player.SendChatMessageInfo("Musisz być w samochodzie, aby móc zamontować część do samochodu");
                        return;
                    }

                    if (player.Vehicle.Model == VehicleModel)
                    {
                        VehicleEntity vehicleToUpgrade = player.Vehicle.GetVehicleEntity();
                        if (vehicleToUpgrade == null)
                        {
                            player.SendChatMessageError("Do tego pojazdu nie możesz zamontować części");
                            return;
                        }
                        if (TuningType == TuningType.Wheels)
                        {
                            Alt.Log("vehicleToUpgrade.GameVehicle.WheelVariation: " + vehicleToUpgrade.GameVehicle.WheelVariation);
                            if (vehicleToUpgrade.GameVehicle.WheelVariation != 0)
                            {
                                player.SendChatMessageError("Część z tej kategorii jest już zamontowana w tym pojeździe, odmontuj ją, aby móc wykonać tą akcje");
                                return;
                            }
                        }
                        else
                        {
                            if (vehicleToUpgrade.GameVehicle.GetMod((byte)VehicleModCategory) != 0)
                            {
                                player.SendChatMessageError("Część z tej kategorii jest już zamontowana w tym pojeździe, odmontuj ją, aby móc wykonać tą akcje");
                                return;
                            }
                        }

                        CharacterEntity ownerVehicle = PlayerExtenstion.GetPlayerByCharacterId(vehicleToUpgrade.DbModel.OwnerId);
                        if (ownerVehicle == null || !ownerVehicle.DbModel.Online)
                        {
                            player.SendChatMessageError("Ten gracz musi być w grze, abyś mógł zamontować część do jego pojazdu");
                            return;
                        }

                        OfferScript.OfferPlayer(player, "Montowanie części", ownerVehicle.AccountEntity.ServerID, OfferType.TuningVehicle, DbModel.Id, 100);
                    }
                    else
                    {
                        player.SendChatMessageError("Ta część nie pasuje do tego pojazdu!");
                    }
                }
                else
                {
                    player.SendChatMessageError("Ta część jest już zamontowana do pojazdu");
                }
            }
            else
            {
                player.SendChatMessageError("Nie masz uprawnień do tego, aby móc zamontować część do samochodu! Zgłoś się do dyrektora swojej firmy, jeśli chcesz ubiegać się o te uprawnienie!");
            }
        }
 public CharacterAnimator(CharacterEntity character)
 {
     this.character = character;
     this.BufferFrames();
 }
Exemplo n.º 21
0
 void StartAttack(CharacterEntity OtherCharacter)
 {
     VisualizationComponent.SetAttackState();
     OtherCharacter.VisualizationComponent.SetAttackState();
 }
    public override void UndoEvent(GameWorldController gameWorldController)
    {
        GameData currentGame = gameWorldController.Model.CurrentGame;

        if (currentGame.CharacterID != _characterState.character_id)
        {
            // Add the character state back into to the current game state
            gameWorldController.Model.CurrentGame.SetCharacterById(_characterState.character_id, _characterState);

            // Create a new character entity using the character data just set in the game state
            {
                CharacterEntity characterEntity = new CharacterEntity(_characterState.character_id);

                characterEntity.AddToGameWorld(gameWorldController);
            }

            base.UndoEvent(gameWorldController);
        }
        else
        {
            Debug.Log("Ignoring undo CharacterLeftGame event for primary character_id=" + _characterState.character_id);
        }
    }
Exemplo n.º 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="item"></param>
 /// <param name="effect"></param>
 /// <param name="targetId"></param>
 /// <param name="targetCell"></param>
 /// <returns></returns>
 public abstract bool ProcessItem(CharacterEntity character, ItemDAO item, GenericEffect effect, long targetId, int targetCell);
Exemplo n.º 24
0
 public void RemoveCharacterEntity(CharacterEntity characterEntity)
 {
     m_characterEntities.Remove(characterEntity.MyCharacterData.character_id);
 }
Exemplo n.º 25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="parameters"></param>
 public abstract bool Process(CharacterEntity character, Dictionary <string, string> parameters);
Exemplo n.º 26
0
 public void StartSequence(CharacterEntity player, BossController boss)
 {
     isFinished = false;
     boss.StartCoroutine(AttackRoutine(player, boss));
 }
Exemplo n.º 27
0
 private void on_ChangeHolder(CharacterEntity entity)
 {
     item.SetHolder(entity);
 }
Exemplo n.º 28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="npc"></param>
 public AuctionHouseSellExchange(CharacterEntity character, NonPlayerCharacterEntity npc)
     : base(ExchangeTypeEnum.EXCHANGE_AUCTION_HOUSE_SELL, character, npc)
 {
 }
Exemplo n.º 29
0
        public override void Update()
        {
            for (int x = 0; x < Entities.Count; x++)
            {
                CharacterEntity e = (CharacterEntity)Entities[x];

                // Update animations of common entities at the same time
                if (coordinatedAnimClock.ElapsedTime.AsMilliseconds() > 100)
                {
                    foreach (CharacterEntity cz in Entities.Where(zx => zx.GetType() == typeof(Mario.Characters.CoinBox)))
                    {
                        cz.sprite.TextureRect = cz.EntitySpriteSheet.GetSprite(Direction.NONE, coordinatedAnimFramePointer);
                    }

                    foreach (CharacterEntity cz in Entities.Where(zx => zx.GetType() == typeof(Mario.Characters.Coin)))
                    {
                        cz.sprite.TextureRect = cz.EntitySpriteSheet.GetSprite(Direction.NONE, coordinatedAnimFramePointer);
                    }

                    coordinatedAnimClock.Restart();
                    coordinatedAnimFramePointer++;
                    if (coordinatedAnimFramePointer >= e.EntitySpriteSheet.SpriteFrames.Count)
                    {
                        coordinatedAnimFramePointer = 0;
                    }
                }

                // Update the entity
                e.Update();
                e.Draw();

                // Constrain speed of jump/fall based on tile height
                if (e.Velocity > viewPort.TileHeight)
                {
                    e.Velocity = viewPort.TileHeight;
                }
                if (e.Velocity < -viewPort.TileHeight)
                {
                    e.Velocity = -viewPort.TileHeight;
                }

                // Check for collisions
                if (e.Y > -1)
                {
                    CheckCharacterCollisions(e);
                }

                // Character is too far offscreen. Kill it.
                if (e.X < -100 || e.X > _gameObject.Window.Size.X + 100)
                {
                    e.Delete = true;
                }
            }

            // Scroll viewport if needed
            ViewportScrollHandler();

            // Update the score, time, etc
            UpdateTextData();


            // Remove and entities flagged for deletion
            // Occurs when an enemy falls in a pit, or scrolls off screen, destroyed by player, etc
            for (int i = Entities.Count - 1; i >= 0; i--)
            {
                if (Entities[i].Delete)
                {
                    Entities.RemoveAt(i);
                }
            }
        }
    public void OnRoomLoaded(RoomKey roomKey)
    {
        RoomData currentRoom = m_gameWorldModel.GetRoomData(roomKey);

        // Get a list of all the characters that are in the same room as my character
        List <int> characterIDList = m_gameWorldModel.GetCharacterIDListInRoom(roomKey);

        // Remove any existing character
        List <int> allCharacterIds = new List <int>(m_gameWorldModel.GetCharacterEntityMap().Keys);

        foreach (int characterEntityId in allCharacterIds)
        {
            CharacterEntity characterEntity = m_gameWorldModel.GetCharacterEntity(characterEntityId);

            characterEntity.RemoveFromGameWorld(this);
        }

        // (Re)Create character entities for each character in the room
        foreach (int characterID in characterIDList)
        {
            CharacterEntity newCharacterEntity = new CharacterEntity(characterID);

            newCharacterEntity.AddToGameWorld(this);
        }

        // Remove any existing mobs
        List <int> allMobIds = new List <int>(m_gameWorldModel.GetMobEntityMap().Keys);

        foreach (int mobEntityId in allMobIds)
        {
            MobEntity mobEntity = m_gameWorldModel.GetMobEntity(mobEntityId);

            mobEntity.RemoveFromGameWorld(this);
        }

        // (Re)Create mob entities for each mob in the room
        foreach (MobData mobData in currentRoom.MobMap.Values)
        {
            MobEntity newMobEntity = new MobEntity(mobData.mob_id);

            newMobEntity.AddToGameWorld(this);
        }

        // Remove any existing energy tanks
        List <int> allEnergyTankIds = new List <int>(m_gameWorldModel.GetEnergyTankEntityMap().Keys);

        foreach (int energyTankId in allEnergyTankIds)
        {
            EnergyTankEntity energyTankEntity = m_gameWorldModel.GetEnergyTankEntity(energyTankId);

            energyTankEntity.RemoveFromGameWorld(this);
        }

        // (Re)Create energy tank entities for each energy tank in the room
        foreach (EnergyTankData energyTankData in currentRoom.EnergyTankMap.Values)
        {
            EnergyTankEntity newEnergyTankEntity = new EnergyTankEntity(energyTankData.energy_tank_id);

            newEnergyTankEntity.AddToGameWorld(this);
        }

        // generate all of the terrain tiles and static objects in the room
        gameWorldView.RebuildRoom(currentRoom);

        // Notify the overlay of a room reload
        m_contextOverlayController.OnRoomLoaded(currentRoom);
    }
Exemplo n.º 31
0
        private void CheckCharacterCollisions(CharacterEntity e)
        {
            // Character collisions
            for (int x = 0; x < Entities.Count; x++)
            {
                CharacterEntity c = (CharacterEntity)Entities[x];

                if (c.IsStatic || c.IgnoreAllCollisions)
                {
                    continue;
                }

                if (c.ID != e.ID)
                {
                    FloatRect entityRect = e.sprite.GetGlobalBounds();
                    FloatRect area       = new FloatRect();

                    FloatRect boundBox = c.sprite.GetGlobalBounds();
                    boundBox.Top    = boundBox.Top + boundBox.Height + 1;
                    boundBox.Height = 1;

                    if (boundBox.Intersects(entityRect))
                    {
                        // Down
                        e.OnCharacterCollision(c, Direction.DOWN);
                        continue;
                    }

                    boundBox        = c.sprite.GetGlobalBounds();
                    boundBox.Top    = boundBox.Top - 1;
                    boundBox.Height = 1;

                    if (boundBox.Intersects(entityRect, out area))
                    {
                        // Up
                        e.OnCharacterCollision(c, Direction.UP);
                        continue;
                    }

                    boundBox       = c.sprite.GetGlobalBounds();
                    boundBox.Left  = boundBox.Left + boundBox.Width;
                    boundBox.Width = 1;

                    if (boundBox.Intersects(entityRect))
                    {
                        // Right
                        e.OnCharacterCollision(c, Direction.LEFT);
                        c.OnCharacterCollision(e, Direction.RIGHT);
                        continue;
                    }

                    boundBox       = c.sprite.GetGlobalBounds();
                    boundBox.Width = 1;

                    if (boundBox.Intersects(entityRect))
                    {
                        // Left
                        e.OnCharacterCollision(c, Direction.RIGHT);
                        c.OnCharacterCollision(e, Direction.LEFT);
                        continue;
                    }
                }
            }
        }
Exemplo n.º 32
0
 public void Offer(CharacterEntity seller, CharacterEntity getter, decimal money)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 33
0
        public override void DrawBackground()
        {
            List <Entity> NewEntities = viewPort.Render();

            foreach (Entity e in NewEntities)
            {
                CharacterEntity c = null;

                switch (e.Name)
                {
                case "goomba": c = new Characters.Goomba(this._gameObject); break;

                case "koopatroopa": c = new Characters.KoopaTroopa(this._gameObject); break;

                case "coinbox": c = new Characters.CoinBox(this._gameObject); break;

                case "emptycoinbox": c = new Characters.EmptyCoinBox(this._gameObject); break;

                case "rock": c = new Characters.Rock(this._gameObject); break;

                case "brick": c = new Characters.Brick(this._gameObject); break;

                case "block": c = new Characters.Block(this._gameObject); break;

                case "goal": c = new Characters.Goal(this._gameObject); break;

                case "pipetopleft": c = new Characters.PipeTopLeft(this._gameObject); break;

                case "pipetopright": c = new Characters.PipeTopRight(this._gameObject); break;

                case "pipeleft": c = new Characters.PipeLeft(this._gameObject); break;

                case "piperight": c = new Characters.PipeRight(this._gameObject); break;

                case "flagpole": c = new Characters.FlagPole(this._gameObject); break;

                case "flag": c = new Characters.Flag(this._gameObject); break;

                case "poletop": c = new Characters.PoleTop(this._gameObject); break;

                case "smallcastle": c = new Characters.SmallCastle(this._gameObject); break;

                case "coin": c = new Characters.Coin(this._gameObject); break;

                case "coinbounce": c = new Characters.CoinBounce(this._gameObject); break;
                }

                c.X             = e.X;
                c.Y             = e.Y;
                c.OriginTileCol = e.OriginTileCol;
                c.OriginTileRow = e.OriginTileRow;

                var xx = Entities.Where(x => x.OriginTileRow == c.OriginTileRow && x.OriginTileCol == c.OriginTileCol);
                if (xx.Count() == 0)
                {
                    Entities.Add(c);
                }
            }

            NewEntities.Clear();
        }
Exemplo n.º 34
0
 public bool CanSpawnCharacter(CharacterEntity character)
 {
     return(isServer && !SpawnedCharacters.Contains(character) && IsSpawnerInsideSpawnableArea());
 }
Exemplo n.º 35
0
 public AttackInfo Attack(CharacterEntity target, float pAtkRate = 1f, float mAtkRate = 1f, int hitCount = 1, int fixDamage = 0)
 {
     return(customBody.Attack(target, pAtkRate, mAtkRate, hitCount, fixDamage));
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="character"></param>
 public CharacterInventory(CharacterEntity character)
     : base(character, (int)EntityTypeEnum.TYPE_CHARACTER, character.Id)
 {
     Character = character;
     Initialize();
 }
Exemplo n.º 37
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <returns></returns>
 public override bool CanJoin(CharacterEntity character)
 {
     return(true);
 }
 public CollisionHandler(CharacterEntity character, List<FallingObject> fallingEntities)
 {
     this.character = character;
     this.fallingEntities = fallingEntities;
 }
Exemplo n.º 39
0
        /// <summary>
        /// Picks up this <see cref="Entity"/>.
        /// </summary>
        /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to pick up this <see cref="Entity"/>.</param>
        /// <returns>True if this <see cref="Entity"/> was successfully picked up, else false.</returns>
        public override bool Pickup(CharacterEntity charEntity)
        {
            const string errmsg = "Client is not allowed to pick up items.";

            Debug.Fail(errmsg);
            if (log.IsErrorEnabled)
                log.Error(errmsg);

            return false;
        }
Exemplo n.º 40
0
 /// <summary>
 /// Checks if this <see cref="Entity"/> can be picked up by the specified <paramref name="charEntity"/>, but does
 /// not actually pick up this <see cref="Entity"/>.
 /// </summary>
 /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to use this <see cref="Entity"/>.</param>
 /// <returns>True if this <see cref="Entity"/> can be picked up, else false.</returns>
 public override bool CanPickup(CharacterEntity charEntity)
 {
     // Every character can pick up an ItemEntity
     return true;
 }
    public override void ApplyEvent(GameWorldController gameWorldController, OnEventCompleteDelegate onComplete)
    {
        base.ApplyEvent(gameWorldController, onComplete);

        CharacterData character = gameWorldController.Model.GetCharacterData(CharacterID);

        // Update the room key and position on the character that changed rooms
        character.room_x = ToRoomKey.x;
        character.room_y = ToRoomKey.y;
        character.room_z = ToRoomKey.z;
        character.x = ToPosition.x;
        character.y = ToPosition.y;
        character.z = ToPosition.z;

        // Character is the current game character
        if (CharacterID == gameWorldController.Model.CurrentCharacterID)
        {
            // Request the static room data for the room the character is portal-ing to
            // event application won't advance while waiting on room data to load from the server.
            // Once we get the new room data we rebuild everything.
            gameWorldController.Model.RequestRoomData(ToRoomKey, onComplete);
        }
        // Character is some other game character
        else
        {
            // Get the character entity for the character id, if any exists
            CharacterEntity entity = gameWorldController.Model.GetCharacterEntity(CharacterID);

            // Character portal-ed to the current room.
            // Make sure the character exists and is at the correct location.
            if (gameWorldController.Model.CurrentGame.CurrentRoomKey.Equals(ToRoomKey))
            {
                if (entity == null)
                {
                    entity = new CharacterEntity(CharacterID);
                    entity.AddToGameWorld(gameWorldController);
                }

                entity.SnapTo(ToPosition, ToAngle);
            }
            // Character left the current room.
            // Make sure the character entity is cleaned up.
            else
            {
                if (entity != null)
                {
                    entity.RemoveFromGameWorld(gameWorldController);
                }
            }

            if (onComplete != null)
            {
                onComplete();
            }
        }
    }
Exemplo n.º 42
0
 // Entities
 public void AddCharacterEntity(CharacterEntity characterEntity)
 {
     if (m_characterEntities.ContainsKey(characterEntity.MyCharacterData.character_id))
     {
         m_characterEntities[characterEntity.MyCharacterData.character_id]= characterEntity;
     }
     else
     {
         m_characterEntities.Add(characterEntity.MyCharacterData.character_id, characterEntity);
     }
 }
Exemplo n.º 43
0
 public abstract IEnumerator AttackRoutine(CharacterEntity player, BossController boss);
Exemplo n.º 44
0
 public AttackInfo ReceiveDamage(CharacterEntity attacker, int pAtk, int mAtk, int acc, float critChance, float critDamageRate,
                                 int hitCount = 1, int fixDamage = 0)
 {
     return(customBody.ReceiveDamage(attacker, pAtk, mAtk, acc, critChance, critDamageRate, hitCount, fixDamage));
 }
Exemplo n.º 45
0
 public static void GiveIdCard(CharacterEntity getter)
 {
     getter.DbModel.HasIdCard = true;
     getter.Save();
 }
Exemplo n.º 46
0
 public Coroutine MoveTo(CharacterEntity character, float speed)
 {
     targetCharacter = character;
     return(MoveTo(character.TempTransform.position, speed));
 }
Exemplo n.º 47
0
 public bool IsSameTeamWith(CharacterEntity target)
 {
     return(target != null && Formation == target.Formation);
 }
Exemplo n.º 48
0
 /// <summary>
 /// Checks if this <see cref="Entity"/> can be picked up by the specified <paramref name="charEntity"/>, but does
 /// not actually pick up this <see cref="Entity"/>.
 /// </summary>
 /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to use this <see cref="Entity"/></param>
 /// <returns>True if this <see cref="Entity"/> can be picked up, else false.</returns>
 public override bool CanPickup(CharacterEntity charEntity)
 {
     // Every character can try to pick up an item
     return true;
 }
    public override void UndoEvent(GameWorldController gameWorldController)
    {
        CharacterData character = gameWorldController.Model.GetCharacterData(CharacterID);

        // Update the room key and position on the character that changed rooms
        character.room_x = FromRoomKey.x;
        character.room_y = FromRoomKey.y;
        character.room_z = FromRoomKey.z;
        character.x = FromPosition.x;
        character.y = FromPosition.y;
        character.z = FromPosition.z;

        // Character is the current game character
        if (CharacterID == gameWorldController.Model.CurrentCharacterID)
        {
            // Request the static room data for the room the character portal-ed from
            // event application won't advance while waiting on room data to load from the server.
            // Once we get the new room data we rebuild everything.
            gameWorldController.Model.RequestRoomData(FromRoomKey, null);
        }
        // Character is some other game character
        else
        {
            // Get the character entity for the character id, if any exists
            CharacterEntity entity = gameWorldController.Model.GetCharacterEntity(CharacterID);

            // Character portal-ed from the current room.
            // Make sure the character exists and is at the correct location.
            if (gameWorldController.Model.CurrentGame.CurrentRoomKey.Equals(FromRoomKey))
            {
                if (entity == null)
                {
                    entity = new CharacterEntity(CharacterID);
                    entity.AddToGameWorld(gameWorldController);
                }

                entity.SnapTo(FromPosition, FromAngle);
            }
            // Character from some other room than the current one.
            // Make sure the character entity is cleaned up.
            else
            {
                if (entity != null)
                {
                    entity.RemoveFromGameWorld(gameWorldController);
                }
            }
        }

        base.UndoEvent(gameWorldController);
    }