public override void OnAwake()
    {
        base.OnAwake();

        instance = this;  // There is only one player, and we can reference it using PlayerEntity.instance
        isSolid = true;  // The player is solid
    }
Beispiel #2
0
        public override void DeSerialize(DeSerializationContext context)
        {
            base.DeSerialize(context);

            int target = context.ReadInt32();
            if (!IsLocal)
                Owner = (PlayerEntity)Root.Instance.Scene.ServerListGet(target);
        }
Beispiel #3
0
 public PlayerEntity AddPlayerEntity(character character, WorldSession session)
 {
     ObjectGUID guid = new ObjectGUID((ulong)character.guid, TypeID.TYPEID_PLAYER);
     PlayerEntity playerEntity = new PlayerEntity(guid, character, session);
     PlayerEntities.Add(playerEntity);
     playerEntity.Setup();
     return playerEntity;
 }
Beispiel #4
0
 public List<ISubscribable> GetChunkEntitiesExceptSelf(PlayerEntity player)
 {
     var entities = new List<ISubscribable>();
     entities.AddRange(PlayerEntities.Where(pe => pe.ObjectGUID.RawGUID != player.ObjectGUID.RawGUID));
     entities.AddRange(CreatureEntities);
     entities.AddRange(GameObjectEntities);
     return entities;
 }
Beispiel #5
0
 public PSMoveKnockBack(PlayerEntity player, float vcos, float vsin, float horizontalSpeed, float verticalSpeed)
     : base(WorldOpcodes.SMSG_MOVE_KNOCK_BACK)
 {
     this.WritePackedUInt64(player.ObjectGUID.RawGUID);
     this.Write((uint)0); // Sequence
     this.Write(vcos);
     this.Write(vsin);
     this.Write(horizontalSpeed);
     this.Write(verticalSpeed);
 }
Beispiel #6
0
 public PSMoveHeartbeat(PlayerEntity player)
     : base(WorldOpcodes.MSG_MOVE_HEARTBEAT)
 {
     this.WritePackedUInt64(player.ObjectGUID.RawGUID);
     this.Write((uint)MovementFlags.MOVEFLAG_NONE);
     this.Write((uint)1); // Time
     this.Write(player.Location.X);
     this.Write(player.Location.Y);
     this.Write(player.Location.Z);
     this.Write(player.Location.Orientation);
     this.Write((uint)0); // ?
 }
Beispiel #7
0
        public PSSpellGo(PlayerEntity caster, IUnitEntity target, uint spellID)
            : base(WorldOpcodes.SMSG_SPELL_GO)
        {
            this.WritePackedUInt64(caster.ObjectGUID.RawGUID);
            this.WritePackedUInt64(target.ObjectGUID.RawGUID);

            this.Write(spellID);
            this.Write((ushort)SpellCastFlags.CAST_FLAG_UNKNOWN9); // Cast Flags!?
            this.Write((byte)1); // Target Length
            this.Write(target.ObjectGUID.RawGUID);
            this.Write((byte)0); // End
            this.Write((ushort)2); // TARGET_FLAG_UNIT
            this.WritePackedUInt64(target.ObjectGUID.RawGUID);
        }
Beispiel #8
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            bool gamePadDisconnected = !gamePadState.IsConnected &&
                                       input.GamePadWasConnected[playerIndex];

            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
            }
            else if (keyboardState.IsKeyDown(Keys.F1))
            {
                if (Mouse.GetState().LeftButton == ButtonState.Pressed
                    && this.LeftClickLock == false
                    && this.localPlayer == null)
                {
                    this.LeftClickLock = true;

                    Point position = new Point
                    {
                        X = Mouse.GetState().X,
                        Y = Mouse.GetState().Y
                    };

                    ITile tile = TileEngine.TileEngine.Map.GetTile(position);

                    if (!tile.IsBlocked)
                    {
                        PlayerEntity pEntity = new PlayerEntity(tile.ToLocation());

                        Texture2D texture = screenManager.Content.Load<Texture2D>("player_blue");
                        Rectangle destinationRectangle = tile.Rect;
                        Rectangle sourceRectangle = Rectangle.Empty;

                        pEntity.SetDrawData(texture, destinationRectangle, sourceRectangle, 0.4f);

                        pEntity.IsBlocked = false;

                        tile.AddEntity(pEntity);

                        this.localPlayer = pEntity;

                        TileEngine.TileEngine.Map.Player = pEntity;
                    }
                }

                if (Mouse.GetState().LeftButton == ButtonState.Released && this.LeftClickLock == true)
                {
                    this.LeftClickLock = false;
                }
            }
            else if (keyboardState.IsKeyDown(Keys.F2) && this.localPlayer == null)
            {
                TileEngine.TileEngine.SetMap();
            }
            else if (keyboardState.IsKeyDown(Keys.F3))
            {
                if (Mouse.GetState().LeftButton == ButtonState.Pressed
                    && this.LeftClickLock == false)
                {
                    this.LeftClickLock = true;

                    Point position = new Point
                    {
                        X = Mouse.GetState().X + TileEngine.TileEngine.mapOriginPosition.X,
                        Y = Mouse.GetState().Y + TileEngine.TileEngine.mapOriginPosition.Y
                    };

                    TileEngine.TileEngine.SelectedTile = TileEngine.TileEngine.Map.GetTile(position);
                }

                if (Mouse.GetState().LeftButton == ButtonState.Released && this.LeftClickLock == true)
                {
                    this.LeftClickLock = false;
                }
            }
            else if (keyboardState.IsKeyDown(Keys.F4))
            {
                TileEngine.TileEngine.IsMinimapOn = !TileEngine.TileEngine.IsMinimapOn;
            }
            else if (keyboardState.IsKeyDown(Keys.F5))
            {
                if (Mouse.GetState().LeftButton == ButtonState.Pressed
                    && this.LeftClickLock == false
                    && this.localPlayer != null)
                {
                    this.LeftClickLock = true;

                    Point position = new Point
                    {
                        X = Mouse.GetState().X + this.localPlayer.Rect.X,
                        Y = Mouse.GetState().Y + this.localPlayer.Rect.Y
                    };

                    ITile tile = TileEngine.TileEngine.Map.GetTile(position);

                    if (!tile.IsBlocked)
                    {
                        BearEntity bEntity = new BearEntity(tile.ToLocation());

                        Texture2D texture = screenManager.Content.Load<Texture2D>("bear");
                        Rectangle destinationRectangle = tile.Rect;
                        Rectangle sourceRectangle = Rectangle.Empty;

                        bEntity.SetDrawData(texture, destinationRectangle, sourceRectangle, 0.4f);

                        bEntity.IsBlocked = false;

                        tile.AddEntity(bEntity);

                        this.bearList.Add(bEntity);

                        TileEngine.TileEngine.Map.BearList.Add(bEntity);
                    }
                }

                if (Mouse.GetState().LeftButton == ButtonState.Released && this.LeftClickLock == true)
                {
                    this.LeftClickLock = false;
                }
            }
            else if (keyboardState.IsKeyDown(Keys.F6))
            {
                if (Mouse.GetState().LeftButton == ButtonState.Pressed
                    && this.LeftClickLock == false
                    && this.localPlayer != null)
                {
                    this.LeftClickLock = true;

                    Point position = new Point
                    {
                        X = Mouse.GetState().X + localPlayer.Rect.X,
                        Y = Mouse.GetState().Y + localPlayer.Rect.Y
                    };

                    ITile tile = TileEngine.TileEngine.Map.GetTile(position);

                    if (!tile.IsBlocked)
                    {
                        LorisEntity lEntity = new LorisEntity(tile.ToLocation());

                        Texture2D texture = screenManager.Content.Load<Texture2D>("loris_LQ");

                        if (random.NextDouble() > 0.5)
                            texture = screenManager.Content.Load<Texture2D>("loris_MQ");

                        Rectangle destinationRectangle = tile.Rect;
                        Rectangle sourceRectangle = Rectangle.Empty;

                        lEntity.SetDrawData(texture, destinationRectangle, sourceRectangle, 0.4f);

                        lEntity.IsBlocked = false;

                        tile.AddEntity(lEntity);

                        this.lorisList.Add(lEntity);

                        TileEngine.TileEngine.Map.LorisList.Add(lEntity);
                    }
                }

                if (Mouse.GetState().LeftButton == ButtonState.Released && this.LeftClickLock == true)
                {
                    this.LeftClickLock = false;
                }
            }
            else if (localPlayer != null)
            {
                // Otherwise move the player position.
                Vector2 movement = Vector2.Zero;

                if (keyboardState.IsKeyDown(Keys.Left))
                {
                    movement.X--;
                }
                else if (keyboardState.IsKeyDown(Keys.Right))
                {
                    movement.X++;
                }
                else if (keyboardState.IsKeyDown(Keys.Up))
                {
                    movement.Y--;
                }
                else if (keyboardState.IsKeyDown(Keys.Down))
                {
                    movement.Y++;
                }

                //Vector2 thumbstick = gamePadState.ThumbSticks.Left;

                //movement.X += thumbstick.X;
                //movement.Y -= thumbstick.Y;

                //if (keyboardState.IsKeyDown(Keys.LeftShift))
                //{
                //    movement = movement * 5;
                //}

                localPlayer.Movement = movement;
            }
        }
 public override TextFile.Token[] TokensEligible(PlayerEntity playerEntity)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
        void Update()
        {
            // Automatically update weapons from inventory when PlayerEntity available
            if (playerEntity != null)
            {
                UpdateHands();
            }
            else
            {
                playerEntity = GameManager.Instance.PlayerEntity;
            }

            // Reset variables if there isn't an attack ongoing
            if (!IsWeaponAttacking())
            {
                // If an attack with a bow just finished, set cooldown
                if (ScreenWeapon.WeaponType == WeaponTypes.Bow && isAttacking)
                {
                    float cooldown = 10 * (100 - playerEntity.Stats.LiveSpeed) + 800;
                    cooldownTime = Time.time + (cooldown / 980); // Approximates classic frame update
                }

                isAttacking        = false;
                isDamageFinished   = false;
                isBowSoundFinished = false;
            }

            // Do nothing while weapon cooldown. Used for bow.
            if (Time.time < cooldownTime)
            {
                return;
            }

            // Do nothing if weapon isn't done equipping
            if ((usingRightHand && EquipCountdownRightHand != 0) ||
                (!usingRightHand && EquipCountdownLeftHand != 0))
            {
                ShowWeapons(false);
                return;
            }

            // Hide weapons and do nothing if spell is ready or cast animation in progress
            if (GameManager.Instance.PlayerEffectManager)
            {
                if (GameManager.Instance.PlayerEffectManager.HasReadySpell || GameManager.Instance.PlayerSpellCasting.IsPlayingAnim)
                {
                    ShowWeapons(false);
                    return;
                }
            }

            // Do nothing if player paralyzed
            if (GameManager.Instance.PlayerEntity.IsParalyzed)
            {
                ShowWeapons(false);
                return;
            }

            // Toggle weapon sheath
            if (!isAttacking && InputManager.Instance.ActionStarted(InputManager.Actions.ReadyWeapon))
            {
                ToggleSheath();
            }

            // Toggle weapon hand
            if (!isAttacking && InputManager.Instance.ActionComplete(InputManager.Actions.SwitchHand))
            {
                ToggleHand();
            }

            // Do nothing if weapons sheathed
            if (Sheathed)
            {
                ShowWeapons(false);
                return;
            }
            else
            {
                ShowWeapons(true);
            }

            // Get if bow is equipped
            bool bowEquipped = (ScreenWeapon && ScreenWeapon.WeaponType == WeaponTypes.Bow);

            // Handle beginning a new attack
            if (!isAttacking)
            {
                if (!DaggerfallUnity.Settings.ClickToAttack || bowEquipped)
                {
                    // Reset tracking if user not holding down 'SwingWeapon' button and no attack in progress
                    if (!InputManager.Instance.HasAction(InputManager.Actions.SwingWeapon))
                    {
                        lastAttackHand = Hand.None;
                        _gesture.Clear();
                        return;
                    }
                }
                else
                {
                    // Player must click to attack
                    if (InputManager.Instance.ActionStarted(InputManager.Actions.SwingWeapon))
                    {
                        isClickAttack = true;
                    }
                    else
                    {
                        _gesture.Clear();
                        return;
                    }
                }
            }

            var attackDirection = MouseDirections.None;

            if (!isAttacking)
            {
                if (bowEquipped)
                {
                    // Ensure attack button was released before starting the next attack
                    if (lastAttackHand == Hand.None)
                    {
                        attackDirection = MouseDirections.Down; // Force attack without tracking a swing for Bow
                    }
                }
                else if (isClickAttack)
                {
                    attackDirection = (MouseDirections)UnityEngine.Random.Range((int)MouseDirections.Left, (int)MouseDirections.DownRight + 1);
                    isClickAttack   = false;
                }
                else
                {
                    attackDirection = TrackMouseAttack(); // Track swing direction for other weapons
                }
            }

            // Start attack if one has been initiated
            if (attackDirection != MouseDirections.None)
            {
                ExecuteAttacks(attackDirection);
                isAttacking = true;
            }

            // Stop here if no attack is happening
            if (!isAttacking)
            {
                return;
            }

            if (!isBowSoundFinished && ScreenWeapon.WeaponType == WeaponTypes.Bow && ScreenWeapon.GetCurrentFrame() == 3)
            {
                ScreenWeapon.PlaySwingSound();
                isBowSoundFinished = true;

                // Remove arrow
                ItemCollection      playerItems = playerEntity.Items;
                DaggerfallUnityItem arrow       = playerItems.GetItem(ItemGroups.Weapons, (int)Weapons.Arrow);
                if (arrow != null)
                {
                    arrow.stackCount--;
                    if (arrow.stackCount <= 0)
                    {
                        playerItems.RemoveItem(arrow);
                    }
                }
            }
            else if (!isDamageFinished && ScreenWeapon.GetCurrentFrame() == ScreenWeapon.GetHitFrame())
            {
                // The attack has reached the hit frame.
                // Attempt to transfer damage based on last attack hand.
                // Get attack hand weapon

                // Transfer damage.
                bool hitEnemy = false;
                WeaponDamage(ScreenWeapon, out hitEnemy);

                // Fatigue loss
                playerEntity.DecreaseFatigue(swingWeaponFatigueLoss);

                // Play swing sound if attack didn't hit an enemy.
                if (!hitEnemy && ScreenWeapon.WeaponType != WeaponTypes.Bow)
                {
                    ScreenWeapon.PlaySwingSound();
                }
                else
                {
                    // Tally skills
                    if (ScreenWeapon.WeaponType == WeaponTypes.Melee || ScreenWeapon.WeaponType == WeaponTypes.Werecreature)
                    {
                        playerEntity.TallySkill(DFCareer.Skills.HandToHand, 1);
                    }
                    else if (usingRightHand && (currentRightHandWeapon != null))
                    {
                        playerEntity.TallySkill(currentRightHandWeapon.GetWeaponSkillID(), 1);
                    }
                    else if (currentLeftHandWeapon != null)
                    {
                        playerEntity.TallySkill(currentLeftHandWeapon.GetWeaponSkillID(), 1);
                    }

                    playerEntity.TallySkill(DFCareer.Skills.CriticalStrike, 1);
                }
                isDamageFinished = true;
            }
        }
Beispiel #11
0
	/// <summary>
	/// Creates the AI tree.
	/// </summary>
	/// <returns>The AI tree.</returns>
	/// <param name="szBlueprintFile">Size blueprint file.</param>
	public AIBehaviourTree	CreateAITree(PlayerEntity player, string szBlueprintFile)
	{
		if (!string.IsNullOrEmpty(szBlueprintFile))
		{
			TextAsset asset = Resources.Load<TextAsset>(szBlueprintFile);
			if (!asset)
				throw new System.NullReferenceException();
			
			// create the monster ai tree
			return AIBehaviourTreeManager.GetSingleton().CreateAIBehaviourTree(
				player.EntityID, new AIEntityContext(player), asset.text);
		}
		
		return default(AIBehaviourTree);
	}
Beispiel #12
0
        protected override int CalculateNewRank(PlayerEntity playerEntity)
        {
            int newRank = base.CalculateNewRank(playerEntity);

            return(AllowGuildExpulsion(playerEntity, newRank));
        }
    // Determines what image icon the player will have
    private Sprite _getImageBasedOnGenre(PlayerEntity pe)
    {
        Sprite genreIcon = Resources.Load("Sprites/Icon_NoGenre") as Sprite;

        switch(pe.Genre)
        {
            case Genre.Fantasy:
                {
                    genreIcon = m_fantasySprite;
                    break;
                }
            case Genre.GraphicNovel:
                {
                    genreIcon = m_comicSprite;
                    break;
                }
            case Genre.Horror:
                {
                    genreIcon = m_horrorSprite;
                    break;
                }
            case Genre.SciFi:
                {
                    genreIcon = m_scifiSprite;
                    break;
                }
            default:
                {
                    break;
                }
        }

        return genreIcon;
    }
Beispiel #14
0
 public void RemovePlayerEntity(PlayerEntity player)
 {
     player.CurrentChunk.RemovePlayerEntity(player);
     PlayerEntities.Remove(player);
 }
Beispiel #15
0
 public PlayerInfoReadResult()
 {
     PlayerEntity = new PlayerEntity();
 }
Beispiel #16
0
 public async Task Add(PlayerEntity player)
 {
     await _playerRepository.Add(player);
 }
 private void SetActiveObject()
 {
     m_activeObj    = GameObject.FindGameObjectWithTag("Player");;
     m_activeEntity = m_activeObj.GetComponent <PlayerEntity>();
 }
Beispiel #18
0
 public void Initialize(PlayerEntity entity)
 {
     this.entity = entity;
 }
 internal override void EndTurn(PlayerEntity player)
 {
 }
 internal override void GiveTurn(PlayerEntity player) =>
 player.state = new HasTurnPlayerState();
Beispiel #21
0
 private void RideOffFromTop(PlayerEntity playerEntity, VehicleEntity vehicleEntity)
 {
     RideOffFromDirection(playerEntity, vehicleEntity, Vector3.up);
 }
Beispiel #22
0
	/// <summary>
	/// Sets the player entity.
	/// </summary>
	/// <param name="entity">Entity.</param>
	public virtual void 	SetPlayer(PlayerEntity entity)
	{
		MainPlayer = entity;
	}
Beispiel #23
0
 public async Task Update(PlayerEntity player)
 {
     await _playerRepository.Update(player);
 }
Beispiel #24
0
 public string CreatePlayer(PlayerEntity playerEntity)
 {
     playerEntity.Id = Guid.NewGuid().ToString();
     _elasticClient.GetClient().Index(playerEntity, i => i.Index("player"));
     return(playerEntity.Id);
 }
Beispiel #25
0
 public async Task Delete(PlayerEntity player)
 {
     await _playerRepository.Remove(player);
 }
Beispiel #26
0
        private void UpdateSessionChunk(PlayerEntity player)
        {
            if (player == null || player.Location == null || player.Location.Moved == false) return;
            var chunkX = (int)Math.Floor(player.Location.X / ChunkSize);
            var chunkY = (int)Math.Floor(player.Location.Y / ChunkSize);

            var chunkLocation = new Vector2(chunkX, chunkY);

            if (player.CurrentChunk != null)
            {
                //If chunk current chunk has not changed, no need to update.
                if (player.CurrentChunk.ChunkLocation.Equals(chunkLocation)) return;
                //If has changedChunk, remove player entity from old chunk
                player.CurrentChunk.RemovePlayerEntity(player);
            }

            //Initialises chunks if they don't exist
            player.SubscribedChunks = GetChunkAndSurroundings(chunkLocation);

            //Add Player to chunk
            this.AddPlayerToChunk(player, EntityChunks[chunkLocation]);
        }
        /// <summary>
        /// Generates an array of items based on loot chance matrix.
        /// </summary>
        /// <param name="key">Starting loot table key. Used for special handling.</param>
        /// <param name="matrix">Loot chance matrix.</param>
        /// <param name="playerLevel">Level of player.</param>
        /// <returns>DaggerfallUnityItem array.</returns>
        public static DaggerfallUnityItem[] GenerateRandomLoot(string key, LootChanceMatrix matrix, PlayerEntity playerEntity)
        {
            float chance;
            List <DaggerfallUnityItem> items = new List <DaggerfallUnityItem>();

            // Random gold
            int goldCount = Random.Range(matrix.MinGold, matrix.MaxGold) * playerEntity.Level;

            if (goldCount > 0)
            {
                items.Add(ItemBuilder.CreateGoldPieces(goldCount));
            }

            // Random weapon
            chance = matrix.WP * playerEntity.Level;
            while (Random.Range(1, 100) < chance)
            {
                items.Add(ItemBuilder.CreateRandomWeapon(playerEntity.Level));
                chance *= 0.5f;
            }

            // Random armor
            chance = matrix.AM * playerEntity.Level;
            while (Random.Range(1, 100) < chance)
            {
                items.Add(ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race));
                chance *= 0.5f;
            }

            // Random ingredients
            RandomIngredient(matrix.C1 * playerEntity.Level, ItemGroups.CreatureIngredients1, items);
            RandomIngredient(matrix.C2 * playerEntity.Level, ItemGroups.CreatureIngredients2, items);
            RandomIngredient(matrix.C3 * playerEntity.Level, ItemGroups.CreatureIngredients3, items);
            RandomIngredient(matrix.P1 * playerEntity.Level, ItemGroups.PlantIngredients1, items);
            RandomIngredient(matrix.P2 * playerEntity.Level, ItemGroups.PlantIngredients2, items);
            RandomIngredient(matrix.M1 * playerEntity.Level, ItemGroups.MiscellaneousIngredients1, items);
            RandomIngredient(matrix.M2 * playerEntity.Level, ItemGroups.MiscellaneousIngredients2, items);

            // TEMP: Magic item chance is just another shot at armor or weapon for now
            chance = matrix.MI * playerEntity.Level;
            while (Random.Range(1, 100) < chance)
            {
                if (Random.value < 0.5f)
                {
                    items.Add(ItemBuilder.CreateRandomWeapon(playerEntity.Level));
                }
                else
                {
                    items.Add(ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race));
                }

                chance *= 0.5f;
            }

            // Random clothes
            chance = matrix.CL * playerEntity.Level;
            while (Random.Range(1, 100) < chance)
            {
                items.Add(ItemBuilder.CreateRandomClothing(playerEntity.Gender));
                chance *= 0.5f;
            }

            // Random books
            chance = matrix.BK * playerEntity.Level;
            while (Random.Range(1, 100) < chance)
            {
                items.Add(ItemBuilder.CreateRandomBook());
                chance *= 0.5f;
            }

            // Random religious item
            chance = matrix.RL * playerEntity.Level;
            while (Random.Range(1, 100) < chance)
            {
                items.Add(ItemBuilder.CreateRandomReligiousItem());
                chance *= 0.5f;
            }

            // Special humanoid handling
            // Daggerfall seems to always drop between 1-3 weapons and 2-5 armor pieces regardless of player level
            // This is probably totally off track, but for now generating closer results than loot table alone
            // TODO: Revisit humanoid loot tables later
            if (key == "HM")
            {
                // Create 1-3 weapons
                int count = Random.Range(1, 3);
                for (int i = 0; i < count; i++)
                {
                    items.Add(ItemBuilder.CreateRandomWeapon(playerEntity.Level));
                }

                // Create 2-5 armor pieces
                count = Random.Range(2, 5);
                for (int i = 0; i < count; i++)
                {
                    items.Add(ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race));
                }
            }

            return(items.ToArray());
        }
Beispiel #28
0
 public void RemovePlayerEntity(PlayerEntity player)
 {
     PlayerEntities.Remove(player);
 }
Beispiel #29
0
        static void AssignEnemyStartingEquipment(PlayerEntity playerEntity, EnemyEntity enemyEntity, int variant)
        {
            // Use default code for non-class enemies.
            if (enemyEntity.EntityType != EntityTypes.EnemyClass)
            {
                DaggerfallUnity.Instance.ItemHelper.AssignEnemyStartingEquipment(playerEntity, enemyEntity, variant);
                return;
            }

            // Set item level, city watch never have items above iron or steel
            int     itemLevel    = (enemyEntity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch) ? 1 : enemyEntity.Level;
            Genders playerGender = playerEntity.Gender;
            Races   playerRace   = playerEntity.Race;
            int     chance       = 50;

            // Held weapon(s) and shield/secondary:
            switch ((MobileTypes)enemyEntity.MobileEnemy.ID)
            {
            // Ranged specialists:
            case MobileTypes.Archer:
            case MobileTypes.Ranger:
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(RandomBow(), ItemBuilder.RandomMaterial(itemLevel)), true);
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon((enemyEntity.MobileEnemy.ID == (int)MobileTypes.Ranger) ? RandomLongblade() : RandomShortblade(), ItemBuilder.RandomMaterial(itemLevel)));
                DaggerfallUnityItem arrowPile = ItemBuilder.CreateWeapon(Weapons.Arrow, WeaponMaterialTypes.Iron);
                arrowPile.stackCount = UnityEngine.Random.Range(4, 17);
                enemyEntity.Items.AddItem(arrowPile);
                chance = 55;
                break;

            // Combat classes:
            case MobileTypes.Barbarian:
            case MobileTypes.Knight:
            case MobileTypes.Knight_CityWatch:
            case MobileTypes.Monk:
            case MobileTypes.Spellsword:
            case MobileTypes.Warrior:
            case MobileTypes.Rogue:
                if (variant == 0)
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(GetCombatClassWeapon((MobileTypes)enemyEntity.MobileEnemy.ID), ItemBuilder.RandomMaterial(itemLevel)), true);
                    // Left hand shield?
                    if (Dice100.SuccessRoll(chance))
                    {
                        AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, RandomShield(), ItemBuilder.RandomArmorMaterial(itemLevel)), true);
                    }
                    // left-hand weapon?
                    else if (Dice100.SuccessRoll(chance))
                    {
                        AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(SecondaryWeapon(), ItemBuilder.RandomMaterial(itemLevel)));
                    }
                    chance = 60;
                }
                else
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(RandomBigWeapon(), ItemBuilder.RandomMaterial(itemLevel)), true);
                    chance = 75;
                }
                if (enemyEntity.MobileEnemy.ID == (int)MobileTypes.Barbarian)
                {
                    chance -= 45;       // Barbies tend to forgo armor
                }
                break;

            // Mage classes:
            case MobileTypes.Mage:
            case MobileTypes.Sorcerer:
            case MobileTypes.Healer:
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(Weapons.Staff, ItemBuilder.RandomMaterial(itemLevel)), true);
                if (Dice100.SuccessRoll(chance))
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(RandomShortblade(), ItemBuilder.RandomMaterial(itemLevel)));
                }
                AddOrEquipWornItem(enemyEntity, (playerGender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Plain_robes, playerEntity.Race) : ItemBuilder.CreateWomensClothing(WomensClothing.Plain_robes, playerEntity.Race), true);
                chance = 30;
                break;

            // Sneaky classes:
            case MobileTypes.Acrobat:
            case MobileTypes.Assassin:
            case MobileTypes.Bard:
            case MobileTypes.Burglar:
            case MobileTypes.Nightblade:
            case MobileTypes.Thief:
            case MobileTypes.Battlemage:
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon((enemyEntity.MobileEnemy.ID == (int)MobileTypes.Battlemage) ? RandomAxeOrBlade() : RandomShortblade(), ItemBuilder.RandomMaterial(itemLevel)), true);
                if (Dice100.SuccessRoll(chance))
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateWeapon(SecondaryWeapon(), ItemBuilder.RandomMaterial(itemLevel / 2)), true);
                }
                chance = 45;
                break;
            }

            // cuirass (everyone gets at least a 50% chance, knights and warriors allways have them)
            if (Dice100.SuccessRoll(Mathf.Max(chance, 50)) || enemyEntity.MobileEnemy.ID == (int)MobileTypes.Knight | enemyEntity.MobileEnemy.ID == (int)MobileTypes.Warrior)
            {
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Cuirass, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
            }
            // greaves (Barbarians always get them)
            if (Dice100.SuccessRoll(chance) || enemyEntity.MobileEnemy.ID == (int)MobileTypes.Barbarian)
            {
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Greaves, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
            }
            // helm (Barbarians always get them)
            if (Dice100.SuccessRoll(chance) || enemyEntity.MobileEnemy.ID == (int)MobileTypes.Barbarian)
            {
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Helm, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
            }
            // boots
            if (Dice100.SuccessRoll(chance))
            {
                AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Boots, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
            }

            if (chance > 50)
            {
                chance -= 15;
                // right pauldron
                if (Dice100.SuccessRoll(chance))
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Right_Pauldron, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
                }
                // left pauldron
                if (Dice100.SuccessRoll(chance))
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Left_Pauldron, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
                }
                // gauntlets
                if (Dice100.SuccessRoll(chance))
                {
                    AddOrEquipWornItem(enemyEntity, ItemBuilder.CreateArmor(playerGender, playerRace, Armor.Gauntlets, ItemBuilder.RandomArmorMaterial(itemLevel)), true);
                }
            }

            // Chance for poisoned weapon
            if (playerEntity.Level > 1)
            {
                DaggerfallUnityItem mainWeapon = enemyEntity.ItemEquipTable.GetItem(EquipSlots.RightHand);
                if (mainWeapon != null)
                {
                    int chanceToPoison = 5;
                    if (enemyEntity.MobileEnemy.ID == (int)MobileTypes.Assassin)
                    {
                        chanceToPoison = 60;
                    }

                    if (Dice100.SuccessRoll(chanceToPoison))
                    {
                        // Apply poison
                        mainWeapon.poisonType = (Poisons)UnityEngine.Random.Range(128, 135 + 1);
                    }
                }
            }
        }
Beispiel #30
0
 private void SetPositionInterpolateMode(PlayerEntity playerEntity)
 {
     playerEntity.position.InterpolateType = (int)PositionInterpolateMode.Discrete;
     playerEntity.position.ServerTime      = _currentTime.CurrentTime;
 }
Beispiel #31
0
        static void AssignSkillEquipment(PlayerEntity playerEntity, CharacterDocument characterDocument)
        {
            Debug.Log("Starting Equipment: Assigning Based on Skills");

            // Set condition of ebony dagger if player has one from char creation questions
            IList daggers = playerEntity.Items.SearchItems(ItemGroups.Weapons, (int)Weapons.Dagger);

            foreach (DaggerfallUnityItem dagger in daggers)
            {
                if (dagger.NativeMaterialValue > (int)WeaponMaterialTypes.Steel)
                {
                    dagger.currentCondition = (int)(dagger.maxCondition * 0.15);
                }
            }

            // Skill based items
            AssignSkillItems(playerEntity, playerEntity.Career.PrimarySkill1);
            AssignSkillItems(playerEntity, playerEntity.Career.PrimarySkill2);
            AssignSkillItems(playerEntity, playerEntity.Career.PrimarySkill3);

            AssignSkillItems(playerEntity, playerEntity.Career.MajorSkill1);
            AssignSkillItems(playerEntity, playerEntity.Career.MajorSkill2);
            AssignSkillItems(playerEntity, playerEntity.Career.MajorSkill3);

            // Starting clothes are gender-specific, randomise shirt dye and pants variant
            DaggerfallUnityItem shortShirt  = null;
            DaggerfallUnityItem casualPants = null;

            if (playerEntity.Gender == Genders.Female)
            {
                shortShirt  = ItemBuilder.CreateWomensClothing(WomensClothing.Short_shirt_closed, playerEntity.Race, 0, ItemBuilder.RandomClothingDye());
                casualPants = ItemBuilder.CreateWomensClothing(WomensClothing.Casual_pants, playerEntity.Race);
            }
            else
            {
                shortShirt  = ItemBuilder.CreateMensClothing(MensClothing.Short_shirt, playerEntity.Race, 0, ItemBuilder.RandomClothingDye());
                casualPants = ItemBuilder.CreateMensClothing(MensClothing.Casual_pants, playerEntity.Race);
            }
            ItemBuilder.RandomizeClothingVariant(casualPants);
            AddOrEquipWornItem(playerEntity, shortShirt, true);
            AddOrEquipWornItem(playerEntity, casualPants, true);

            // Add spellbook, all players start with one - also a little gold and a crappy iron dagger for those with no weapon skills.
            playerEntity.Items.AddItem(ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Spellbook));
            playerEntity.Items.AddItem(ItemBuilder.CreateGoldPieces(UnityEngine.Random.Range(5, playerEntity.Career.Luck)));
            playerEntity.Items.AddItem(ItemBuilder.CreateWeapon(Weapons.Dagger, WeaponMaterialTypes.Iron));

            // Add some torches and candles if player torch is from items setting enabled
            if (DaggerfallUnity.Settings.PlayerTorchFromItems)
            {
                for (int i = 0; i < 2; i++)
                {
                    playerEntity.Items.AddItem(ItemBuilder.CreateItem(ItemGroups.UselessItems2, (int)UselessItems2.Torch));
                }
                for (int i = 0; i < 4; i++)
                {
                    playerEntity.Items.AddItem(ItemBuilder.CreateItem(ItemGroups.UselessItems2, (int)UselessItems2.Candle));
                }
            }

            Debug.Log("Starting Equipment: Assigning Finished");
        }
Beispiel #32
0
 protected virtual int AllowGuildExpulsion(PlayerEntity playerEntity, int newRank)
 {
     // Thieves guild never expel members (I assume at some point they 'retire' you instead!)
     return((newRank < 0) ? 0 : newRank);
 }
Beispiel #33
0
        static void AssignSkillItems(PlayerEntity playerEntity, DFCareer.Skills skill)
        {
            ItemCollection items  = playerEntity.Items;
            Genders        gender = playerEntity.Gender;
            Races          race   = playerEntity.Race;

            bool upgrade = Dice100.SuccessRoll(playerEntity.Career.Luck / (playerEntity.Career.Luck < 56 ? 2 : 1));
            WeaponMaterialTypes weaponMaterial = WeaponMaterialTypes.Iron;

            if ((upgrade && !playerEntity.Career.IsMaterialForbidden(DFCareer.MaterialFlags.Steel)) || playerEntity.Career.IsMaterialForbidden(DFCareer.MaterialFlags.Iron))
            {
                weaponMaterial = WeaponMaterialTypes.Steel;
            }
            ArmorMaterialTypes armorMaterial = ArmorMaterialTypes.Leather;

            if ((upgrade && !playerEntity.Career.IsArmorForbidden(DFCareer.ArmorFlags.Chain)) || playerEntity.Career.IsArmorForbidden(DFCareer.ArmorFlags.Leather))
            {
                armorMaterial = ArmorMaterialTypes.Chain;
            }

            switch (skill)
            {
            case DFCareer.Skills.Archery:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Weapons.Short_Bow, weaponMaterial));
                DaggerfallUnityItem arrowPile = ItemBuilder.CreateWeapon(Weapons.Arrow, WeaponMaterialTypes.Iron);
                arrowPile.stackCount = 30;
                items.AddItem(arrowPile);
                return;

            case DFCareer.Skills.Axe:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Battle_Axe : Weapons.War_Axe, weaponMaterial)); return;

            case DFCareer.Skills.Backstabbing:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Right_Pauldron, armorMaterial)); return;

            case DFCareer.Skills.BluntWeapon:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Mace : Weapons.Flail, weaponMaterial)); return;

            case DFCareer.Skills.Climbing:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Helm, armorMaterial, -1)); return;

            case DFCareer.Skills.CriticalStrike:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Greaves, armorMaterial)); return;

            case DFCareer.Skills.Dodging:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Casual_cloak, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Casual_cloak, race)); return;

            case DFCareer.Skills.Etiquette:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Formal_tunic, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Evening_gown, race)); return;

            case DFCareer.Skills.HandToHand:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Gauntlets, armorMaterial)); return;

            case DFCareer.Skills.Jumping:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Boots, armorMaterial)); return;

            case DFCareer.Skills.Lockpicking:
                items.AddItem(ItemBuilder.CreateRandomPotion()); return;

            case DFCareer.Skills.LongBlade:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Saber : Weapons.Broadsword, weaponMaterial)); return;

            case DFCareer.Skills.Medical:
                DaggerfallUnityItem bandages = ItemBuilder.CreateItem(ItemGroups.UselessItems2, (int)UselessItems2.Bandage);
                bandages.stackCount = 4;
                items.AddItem(bandages);
                return;

            case DFCareer.Skills.Mercantile:
                items.AddItem(ItemBuilder.CreateGoldPieces(UnityEngine.Random.Range(playerEntity.Career.Luck, playerEntity.Career.Luck * 4))); return;

            case DFCareer.Skills.Pickpocket:
                items.AddItem(ItemBuilder.CreateRandomGem()); return;

            case DFCareer.Skills.Running:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Shoes, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Shoes, race)); return;

            case DFCareer.Skills.ShortBlade:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateWeapon(Dice100.SuccessRoll(50) ? Weapons.Shortsword : Weapons.Tanto, weaponMaterial)); return;

            case DFCareer.Skills.Stealth:
                AddOrEquipWornItem(playerEntity, (gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Khajiit_suit, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Khajiit_suit, race)); return;

            case DFCareer.Skills.Streetwise:
                AddOrEquipWornItem(playerEntity, ItemBuilder.CreateArmor(gender, race, Armor.Cuirass, armorMaterial)); return;

            case DFCareer.Skills.Swimming:
                items.AddItem((gender == Genders.Male) ? ItemBuilder.CreateMensClothing(MensClothing.Loincloth, race) : ItemBuilder.CreateWomensClothing(WomensClothing.Loincloth, race)); return;

            case DFCareer.Skills.Daedric:
            case DFCareer.Skills.Dragonish:
            case DFCareer.Skills.Giantish:
            case DFCareer.Skills.Harpy:
            case DFCareer.Skills.Impish:
            case DFCareer.Skills.Orcish:
                items.AddItem(ItemBuilder.CreateRandomBook());
                for (int i = 0; i < 4; i++)
                {
                    items.AddItem(ItemBuilder.CreateRandomIngredient(ItemGroups.CreatureIngredients1));
                }
                return;

            case DFCareer.Skills.Centaurian:
            case DFCareer.Skills.Nymph:
            case DFCareer.Skills.Spriggan:
                items.AddItem(ItemBuilder.CreateRandomBook());
                for (int i = 0; i < 4; i++)
                {
                    items.AddItem(ItemBuilder.CreateRandomIngredient(ItemGroups.PlantIngredients1));
                }
                return;
            }
        }
Beispiel #34
0
 public void TransitionFloors(PlayerEntity oldPlayer)
 {
     HitPoints = oldPlayer.HitPoints;
     OurInventory = oldPlayer.OurInventory;
 }
Beispiel #35
0
        static void AssignSkillSpells(PlayerEntity playerEntity, DFCareer.Skills skill, bool primary = false)
        {
            ItemCollection items  = playerEntity.Items;
            Genders        gender = playerEntity.Gender;
            Races          race   = playerEntity.Race;

            switch (skill)
            {
            // Classic spell indexes are on https://en.uesp.net/wiki/Daggerfall:SPELLS.STD_indices under Spell Catalogue
            case DFCareer.Skills.Alteration:
                playerEntity.AddSpell(gentleFallSpell);             // Gentle Fall
                if (primary)
                {
                    playerEntity.AddSpell(GetClassicSpell(38));     // Jumping
                }
                return;

            case DFCareer.Skills.Destruction:
                playerEntity.AddSpell(arcaneArrowSpell);            // Arcane Arrow
                if (primary)
                {
                    playerEntity.AddSpell(minorShockSpell);         // Minor shock
                }
                return;

            case DFCareer.Skills.Illusion:
                playerEntity.AddSpell(candleSpell);                 // Candle
                if (primary)
                {
                    playerEntity.AddSpell(GetClassicSpell(44));     // Chameleon
                }
                return;

            case DFCareer.Skills.Mysticism:
                playerEntity.AddSpell(knockSpell);                  // Knock
                playerEntity.AddSpell(knickKnackSpell);             // Knick-Knack
                if (primary)
                {
                    playerEntity.AddSpell(GetClassicSpell(1));      // Fenrik's Door Jam
                    playerEntity.AddSpell(GetClassicSpell(94));     // Recall!
                }
                return;

            case DFCareer.Skills.Restoration:
                playerEntity.AddSpell(salveBruiseSpell);             // Salve Bruise
                if (primary)
                {
                    playerEntity.AddSpell(smellingSaltsSpell);      // Smelling Salts
                    playerEntity.AddSpell(GetClassicSpell(97));     // Balyna's Balm
                }
                return;

            case DFCareer.Skills.Thaumaturgy:
                playerEntity.AddSpell(GetClassicSpell(2));          // Buoyancy
                if (primary)
                {
                    playerEntity.AddSpell(riseSpell);               // Rise
                }
                return;
            }
        }
Beispiel #36
0
    void Start()
    {
        native_width = Screen.width;
        native_height = Screen.height;

        AbilitiesOuterBox = new Rect(Screen.width * .251f,Screen.height * .90269f, Screen.width *.208385f, Screen.height *.09944f);
        AbilityOneBox = new Rect(Screen.width * .01f,Screen.height * .0f, Screen.width *.03695f, Screen.height *.09f);
        AbilityTwoBox = new Rect(Screen.width * .045854f,Screen.height * .00455f, Screen.width *.038f, Screen.height *.08799f);
        AbilityThreeBox = new Rect(Screen.width * .0875776f,Screen.height * .0f, Screen.width *.036f, Screen.height *.09f);
        AbilityFourBox = new Rect(Screen.width * .1264f,Screen.height * .0f, Screen.width *.03776f, Screen.height *.09f);
        AbilityFiveBox = new Rect(Screen.width * .1646f,Screen.height * .0f, Screen.width *.03776f, Screen.height *.09f);

        HealthOverlayPos.x = 0f;
        HealthOverlayPos.y = 0f;
        HealthOverlaySize.x = Screen.width * .491f;// 300f;//.491f
        HealthOverlaySize.y = Screen.height * .21834f;//100f;//.21834f

        currentLiquidPos.x = Screen.width * .019399f;//12f;//.019399f
        currentLiquidPos.y = Screen.height * .21834f;//100f;//.21834f
        currentLiquidSize.x = Screen.width * .17f;//104f;//.17f
        currentLiquidSize.y = Screen.height * .1986999f;//91f;//.1986999f

        HealthGroupPos.x = 0f;//
        HealthGroupPos.y = Screen.height * .78f;//358f;//.78f
        HealthGroupSize.x = Screen.width * .491f;//300f;//.491f
        HealthGroupSize.y = Screen.height * .21834f;//100f;//.21834f

        InfoBox1 = new Rect(Screen.width * .5f, Screen.height * .87f, Screen.width * .45f, Screen.height * .1f);
        InfoBox2 = new Rect(Screen.width * .91f, Screen.height * .90f, Screen.width * .45f, Screen.height * .1f);

        player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerEntity>();
        currentLiquid = HealthLiquid;

        #region Cooldown GUI init

        CDBox1 = new Rect(Screen.width * .65f, Screen.height * .875f, Screen.width * .45f, Screen.height * .1f);
        CDBox2 = new Rect(Screen.width * .65f, Screen.height * .900f, Screen.width * .45f, Screen.height * .1f);
        CDBox3 = new Rect(Screen.width * .65f, Screen.height * .925f, Screen.width * .45f, Screen.height * .1f);
        CDBox4 = new Rect(Screen.width * .65f, Screen.height * .950f, Screen.width * .45f, Screen.height * .1f);
        CDBox5 = new Rect(Screen.width * .65f, Screen.height * .975f, Screen.width * .45f, Screen.height * .1f);

        #endregion

        TempManaBox = new Rect(Screen.width * .9f, Screen.height * .80f, Screen.width * .45f, Screen.height * .1f);
    }
Beispiel #37
0
 public Room EnterDefaultRoom(PlayerEntity player)
 {
     return(EnterRoom(player, defaultRoomTemplate.templateID, defaultRoomID));
 }
Beispiel #38
0
	/// <summary>
	/// Start this instance.
	/// </summary>
	void Start()
	{
		MainPlayer = PlayerMgr.GetPlayer();
		if (!MainPlayer)
			throw new System.NullReferenceException();
	}
Beispiel #39
0
 public void LeaveRoom(PlayerEntity player, Room room)
 {
     player.room.RemovePlayer(player);
 }
			public void Read(string line)
			{
				if(HeroesAreKnown)
				{
					return;
				}
				
				var playerMatch = playerRegex.Match(line);
				var playerHand = playerHandRegex.Match(line);
				var heroZone = heroZoneRegex.Match(line);
				
				if(playerMatch.Success)
				{
					// possible new game, reset PlayerEntities
					Player = new PlayerEntity();
					Opponent = new PlayerEntity();
					idsAreKnown = false;
					hasPlayerLine = true;
				}
				else if(playerHand.Success && hasPlayerLine)
				{
					hasPlayerLine = false;
					// if id already assigned skip rest
					if(Player.Id != 0)
						return;
					Player.Id = int.Parse(playerHand.Groups[1].Value);
					Player.IsPlayer = true; // TODO: this is a bit pointless
					// assuming ids are either 1 or 2!
					Opponent.Id = Player.Id == 1 ? 2 : 1;
					idsAreKnown = true;							
				}
				else if(heroZone.Success && idsAreKnown)
				{
					var hid = int.Parse(heroZone.Groups[2].Value);
					if(hid == Player.Id)
					{
						Player.Hero = heroZone.Groups[1].Value;
					}
					else if(hid == Opponent.Id)
					{
						Opponent.Hero = heroZone.Groups[1].Value;
					}
					if(HeroesAreKnown)
					{
						SetPlayers();
					}
				}
			}
Beispiel #41
0
        public override void UpdatePlayerRotation(ICameraMotorInput input, ICameraMotorState state, PlayerEntity player)
        {
            if (!input.IsDead && CanRotatePlayer(state))
            {
                float newDeltaAngle = input.DeltaYaw;

                if (player.playerRotateLimit.LimitAngle)
                {
                    var candidateAngle = YawPitchUtility.Normalize(player.orientation.Yaw) + input.DeltaYaw;
                    candidateAngle = Mathf.Clamp(candidateAngle, player.playerRotateLimit.LeftBound,
                                                 player.playerRotateLimit.RightBound);
                    player.orientation.Yaw = CalculateFrameVal(candidateAngle, 0f, _config.YawLimit);
                }
                else
                {
                    player.orientation.Yaw = CalculateFrameVal(player.orientation.Yaw, newDeltaAngle, _config.YawLimit);
                }

                //               newDeltaAngle = player.characterContoller.Value.PreRotateAngle(player.orientation.ModelView, player.position.Value,input.DeltaYaw, input.FrameInterval * 0.001f);

//                Logger.DebugFormat("deltaAngle:{0},prevAngle:{1}, curYaw:{2}, input.DeltaYaw:{4},player.orientationLimit.LimitAngle:{5}",
//                    newDeltaAngle,
//                    player.orientation.Yaw,
//                    CalculateFrameVal(player.orientation.Yaw, newDeltaAngle, _config.YawLimit),
//                    input.DeltaYaw
//                );

                var deltaPitch = HandlePunchPitch(player, input);
                player.orientation.Pitch =
                    CalculateFrameVal(player.orientation.Pitch, deltaPitch, _config.PitchLimit);
            }
        }
    // Use this for initialization
    void Start()
    {
        targetPosition = Vector3.zero;
        agent = GetComponent<NavMeshAgent>();

        entity = GetComponent<PlayerEntity>();
        moveFSM = GetComponent<MovementFSM>();
        combatFSM = GetComponent<CombatFSM>();
    }
Beispiel #43
0
 public bool HasBeenTouchedByPlayer(PlayerEntity player)
 {
     return(_touchedByPlayers.Contains(player));
 }
Beispiel #44
0
    void Start()
    {
        nativeResolution.x = Screen.width;
        nativeResolution.y = Screen.height;

        playerController = GameObject.FindWithTag("Player").GetComponent<PlayerController>();
        player = GameObject.FindWithTag("Player").GetComponent<PlayerEntity>();

        guiState = States.INGAME;

        stateMachine = new UIStateMachine((int)States.MACHINE_ROOT, this);
        stateMachine.AddDefaultState(new InGameUI((int)States.INGAME, this));
        stateMachine.AddState(new MenuUI((int)States.MENU, this));
        stateMachine.AddState(new CharacterUI((int)States.CHARACTER, this));
        stateMachine.AddState(new LevelupUI((int)States.LEVELUP, this));
        stateMachine.AddState(new TalentUI((int)States.TALENT, this));
        stateMachine.AddState(new SpellbookUI((int)States.SPELLBOOK, this));
        stateMachine.AddState(new AttributesUI((int)States.ATTRIBUTES, this));
        stateMachine.AddState(new LootUI((int)States.LOOT, this));

        style.normal.textColor = Color.white;

        draggedEquip = null;
    }
Beispiel #45
0
    /// <summary>
    /// 是否是管理员
    /// </summary>
    /// <param name="groupId"></param>
    /// <param name="playerId"></param>
    /// <returns></returns>
    public bool isManager(int groupId, int playerId)
    {
        PlayerEntity player = GetMember(groupId, playerId);

        return(player.isManager);
    }
Beispiel #46
0
 public PlayerPacketBuilder(PlayerEntity entity)
 {
     this.entity = entity;
 }
Beispiel #47
0
 public CommonHitMaskController(PlayerContext playerContext, PlayerEntity playerEntity)
 {
     _playerEntity  = playerEntity;
     _playerContext = playerContext;
 }
Beispiel #48
0
 private void AddPlayerToChunk(PlayerEntity player, EntityChunk entityChunk)
 {
     player.CurrentChunk = entityChunk;
     if (!entityChunk.PlayerEntities.Contains(player)) entityChunk.PlayerEntities.Add(player);
 }
Beispiel #49
0
        public override TextFile.Token[] TokensIneligible(PlayerEntity playerEntity)
        {
            int msgId = (GetReputation(playerEntity) < 0) ? IneligibleBadRepId : IneligibleLowSkillId;

            return(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(msgId));
        }
Beispiel #50
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerEntity>();
 }
Beispiel #51
0
 public override TextFile.Token[] TokensEligible(PlayerEntity playerEntity)
 {
     return(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(EligibleMsgId));
 }
Beispiel #52
0
 public override void PreProcessInput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state)
 {
     UpdatePlayerRotation(input, state, player);
 }
Beispiel #53
0
        private bool DistanceTooLarge(PlayerEntity playerEntity, VehicleEntity vehicle)
        {
            var distance = Vector3.Distance(playerEntity.position.Value, vehicle.position.Value);

            return(distance > MaxVehicleEnterDistance);
        }