Exemple #1
0
        public Character()
        {
            _class = CharacterEnums.CharacterClass.Explorer;
            _race = CharacterEnums.CharacterRace.Human;
            _gender = CharacterEnums.Genders.Female;
            _skinColor = CharacterEnums.SkinColors.Fair;
            _skinType = CharacterEnums.SkinType.Flesh;
            _hairColor = CharacterEnums.HairColors.Black;
            _eyeColor = CharacterEnums.EyeColors.Brown;
            _build = CharacterEnums.BodyBuild.Medium;

            _koCount = new Tuple<int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = CharacterEnums.Languages.Common;
            KnownLanguages = new HashSet<Languages>();
            KnownLanguages.Add(_primaryLanguage);

            FirstName = "";
            LastName = "";
            Description = "";
            Age = 17;   //Do we want an age? And are we going to advance it every in game year?  We'll need a birthdate for this.
            Weight = 180; //pounds or kilos?
            Height = 70;  //inches or centimeters?
            Location = "A1";
            InCombat = false;
            LastCombatTime = DateTime.MinValue.ToUniversalTime();
            IsNPC = false;
            Leveled = false;
            MainHand = "WIELD_RIGHT";
            NextLevelExperience = 300;
            Level = 1;
            Experience = 0;
            PointsToSpend = 0;

            Inventory = new Inventory();
            Equipment = new Equipment();
            Bonuses = new StatBonuses();

            Inventory.playerID = this.ID;
            Equipment.playerID = this.ID;

            Attributes = new Dictionary<string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(150, "Hitpoints", 150, 0.1, 1));
            Attributes.Add("Dexterity", new Attribute(10, "Dexterity", 5, 0, 1));
            Attributes.Add("Strength", new Attribute(10, "Strength", 5, 0, 1));
            Attributes.Add("Intelligence", new Attribute(10, "Intelligence", 5, 0, 1));
            Attributes.Add("Endurance", new Attribute(10, "Endurance", 5, 0, 1));
            Attributes.Add("Charisma", new Attribute(10, "Charisma", 5, 0, 1));

            SubAttributes = new Dictionary<string, double>();

            SubAttributes.Add("Agility", 1);
            SubAttributes.Add("Toughness", 1);
            SubAttributes.Add("Cunning", 1);
            SubAttributes.Add("Wisdom", 1);
            SubAttributes.Add("Leadership", 1);
        }
Exemple #2
0
    public override List <PathPoint> FindPath(Vector2 characterPosition, Vector2 taskPosition, int endPointLayer)
    {
        // Начинаем с конца, чтобы двигаться от меньшего приоритета (земли) к большему (тоннели)
        CharacterActionState taskEndPointState = cellActionsStates.Find(state => Utils.MaskToLayer(state.actionLayerMask) == endPointLayer);

        if (taskEndPointState != null)
        {
            // Создаем точку, в которую при поиске будут помещаться все остальные точки поиска. Первый слой - конечная точка
            allAvailablePaths = new PathPoint(taskEndPointState, taskPosition, Vector2.zero);

            checkedPositions.Clear();
            // FindPathTreeToCharacter внутри обновляет allAvailablePaths, добавляя все возможные пути, а возвращает точки до персонажа
            List <PathPoint> lastPointsToCharacter = FindPointsToCharacter(allAvailablePaths.NestLevel, characterPosition);

            if (lastPointsToCharacter != null && lastPointsToCharacter.Count > 0)
            {
                return(GetPathFromLastPoints(lastPointsToCharacter));
            }
            else
            {
                Debugger.Log("Путь не найден", "red");
            }
        }
        return(new List <PathPoint>());
    }
Exemple #3
0
    public async void UpdatePlannedRoutine()
    {
        if (CharacterActionState != CharacterActionState.Idle)
        {
            return;
        }

        if (RoutineManager.AvailableRoutineTypes.Count == 0)
        {
            Logger.Warning("Available routine types is 0!");
            return;
        }

        if (PlannedRoutine.RoutineTasks.Count == 0)
        {
            PlannedRoutine.TryGetNewRoutineTask();
            if (PlannedRoutine.RoutineTasks.Count == 0)
            {
                return;
            }
        }

        PlannedRoutine.InRoutine = true;
        await PlannedRoutine.RoutineTasks[0].Run();

        if (PlannedRoutine.InRoutine)
        {
            PlannedRoutine.InRoutine = false;
            CharacterActionState     = CharacterActionState.Idle;
            if (PlannedRoutine.RoutineTasks.Count > 0)
            {
                PlannedRoutine.RoutineTasks.RemoveAt(0);
            }
        }
    }
Exemple #4
0
        public Character()
        {
            _class     = CharacterEnums.CharacterClass.Explorer;
            _race      = CharacterEnums.CharacterRace.Human;
            _gender    = CharacterEnums.Genders.Female;
            _skinColor = CharacterEnums.SkinColors.Fair;
            _skinType  = CharacterEnums.SkinType.Flesh;
            _hairColor = CharacterEnums.HairColors.Black;
            _eyeColor  = CharacterEnums.EyeColors.Brown;
            _build     = CharacterEnums.BodyBuild.Medium;

            _koCount     = new Tuple <int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = CharacterEnums.Languages.Common;
            KnownLanguages   = new HashSet <Languages>();
            KnownLanguages.Add(_primaryLanguage);

            FirstName           = "";
            LastName            = "";
            Description         = "";
            Age                 = 17;  //Do we want an age? And are we going to advance it every in game year?  We'll need a birthdate for this.
            Weight              = 180; //pounds or kilos?
            Height              = 70;  //inches or centimeters?
            Location            = "A1";
            InCombat            = false;
            LastCombatTime      = DateTime.MinValue.ToUniversalTime();
            IsNPC               = false;
            Leveled             = false;
            MainHand            = "WIELD_RIGHT";
            NextLevelExperience = 300;
            Level               = 1;
            Experience          = 0;
            PointsToSpend       = 0;

            Inventory = new Inventory();
            Equipment = new Equipment();
            Bonuses   = new StatBonuses();

            Inventory.playerID = this.ID;
            Equipment.playerID = this.ID;

            Attributes = new Dictionary <string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(150, "Hitpoints", 150, 0.1, 1));
            Attributes.Add("Dexterity", new Attribute(10, "Dexterity", 5, 0, 1));
            Attributes.Add("Strength", new Attribute(10, "Strength", 5, 0, 1));
            Attributes.Add("Intelligence", new Attribute(10, "Intelligence", 5, 0, 1));
            Attributes.Add("Endurance", new Attribute(10, "Endurance", 5, 0, 1));
            Attributes.Add("Charisma", new Attribute(10, "Charisma", 5, 0, 1));

            SubAttributes = new Dictionary <string, double>();

            SubAttributes.Add("Agility", 1);
            SubAttributes.Add("Toughness", 1);
            SubAttributes.Add("Cunning", 1);
            SubAttributes.Add("Wisdom", 1);
            SubAttributes.Add("Leadership", 1);
        }
Exemple #5
0
 void Blocking()
 {
     if (!IsBlocking)
     {
         ActionState = CharacterActionState.NoAction;
     }
 }
Exemple #6
0
 void Attacking()
 {
     if (!IsAttacking)
     {
         ActionState = CharacterActionState.NoAction;
         playerController.MyAnimator.SetInteger("Attack", 0);
     }
 }
Exemple #7
0
 void HitAction()
 {
     if (!IsHit)
     {
         playerController.MyAnimator.SetBool("Hit", false);
         ActionState = CharacterActionState.NoAction;
     }
 }
Exemple #8
0
    public void Roll(string direction)
    {
        string roll = "Roll" + direction;

        playerController.MyAnimator.SetTrigger(roll);
        IsRolling   = true;
        ActionState = direction.Equals("Left") ? CharacterActionState.RollingLeft : CharacterActionState.RollingRight;
    }
Exemple #9
0
 public void BlockBroken()
 {
     ActionState = CharacterActionState.BlockDamaged;
     playerController.MyAnimator.SetBool("BlockBroken", true);
     playerController.MyAnimator.SetBool("Block", false);
     IsBlocking = false;
     ((Blocking)playerController).BlockBroken();
 }
Exemple #10
0
        /// <summary>
        /// Deep copy constructor
        /// </summary>
        /// <param name="copy"></param>
        public Character(Character copy)   //copy constructor
        {
            _class       = copy._class;
            _race        = copy._race;
            _gender      = copy._gender;
            _skinColor   = copy._skinColor;
            _skinType    = copy._skinType;
            _hairColor   = copy._hairColor;
            _eyeColor    = copy._eyeColor;
            _build       = copy._build;
            _koCount     = new Tuple <int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = copy._primaryLanguage;
            KnownLanguages   = new HashSet <Languages>();
            foreach (CharacterEnums.Languages lang in copy.KnownLanguages)
            {
                KnownLanguages.Add(lang);
            }

            FirstName           = copy.FirstName;
            LastName            = copy.LastName;
            Description         = copy.Description;
            Age                 = copy.Age;    //Do we want an age? And are we going to advance it every in game year?  Players could be 400+ years old rather quick.
            Weight              = copy.Weight; //pounds or kilos?
            Height              = copy.Height; //inches or centimeters?
            Location            = "A1";
            InCombat            = false;
            LastCombatTime      = DateTime.MinValue.ToUniversalTime();
            IsNPC               = false;
            Leveled             = false;
            NextLevelExperience = 300;
            Level               = 1;
            Experience          = 0;
            PointsToSpend       = 0;
            MainHand            = "WIELD_RIGHT";


            Attributes = new Dictionary <string, Attribute>();

            foreach (KeyValuePair <string, Attribute> attrib in copy.Attributes)
            {
                Attributes.Add(attrib.Key, attrib.Value);
            }

            SubAttributes = new Dictionary <string, double>();

            foreach (KeyValuePair <string, double> subAttrib in copy.SubAttributes)
            {
                SubAttributes.Add(subAttrib.Key, subAttrib.Value);
            }

            Inventory = new Inventory();


            this.Save();
        }
    public override IEnumerator OnEnd()
    {
        yield return(base.OnEnd());

        // После выполнения копания выполняем переход к раскопанной клетке
        CharacterActionState activatedState = actionData.taskManager.ActivateState(moveState, actionData.endPosition, actionData.actionDirection);

        yield return(activatedState.Execute());
    }
Exemple #12
0
 public void Hit()
 {
     if (!IsHit)
     {
         ActionState = CharacterActionState.Hit;
         playerController.MyAnimator.SetBool("Hit", true);
         IsHit = true;
     }
 }
Exemple #13
0
 public CharacterAction(CharacterTaskManager taskManager, CharacterSkillsManager skillsManager, CharacterActionState state, Vector2 startPosition, Vector2 endPosition, Vector2 actionDirection)
 {
     this.taskManager     = taskManager;
     this.skillsManager   = skillsManager;
     this.state           = state;
     this.startPosition   = startPosition;
     this.endPosition     = endPosition;
     this.actionDirection = actionDirection;
 }
Exemple #14
0
        public Character(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build)
        {
            _class     = characterClass;
            _race      = race;
            _gender    = gender;
            _skinColor = skinColor;
            _skinType  = skinType;
            _hairColor = hairColor;
            _eyeColor  = eyeColor;
            _build     = build;

            _koCount     = new Tuple <int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = language;
            KnownLanguages   = new HashSet <Languages>();
            KnownLanguages.Add(_primaryLanguage);

            FirstName           = "";
            LastName            = "";
            Description         = "";
            Age                 = 17;     //Do we want an age? And are we going to advance it every in game year?
            Weight              = 180.0d; //pounds or kilos?
            Height              = 70.0d;  //inches or centimeters?
            Location            = "A1";
            InCombat            = false;
            LastCombatTime      = DateTime.MinValue.ToUniversalTime();
            IsNPC               = false;
            Leveled             = false;
            MainHand            = "WIELD_RIGHT";
            NextLevelExperience = 300;
            Level               = 1;
            Experience          = 0;
            PointsToSpend       = 0;

            Inventory = new Inventory();
            Bonuses   = new StatBonuses();

            Attributes = new Dictionary <string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(150, "Hitpoints", 150, 0.1, 1));
            Attributes.Add("Dexterity", new Attribute(10, "Dexterity", 5, 0, 1));
            Attributes.Add("Strength", new Attribute(10, "Strength", 5, 0, 1));
            Attributes.Add("Intelligence", new Attribute(10, "Intelligence", 5, 0, 1));
            Attributes.Add("Endurance", new Attribute(10, "Endurance", 5, 0, 1));
            Attributes.Add("Charisma", new Attribute(10, "Charisma", 5, 0, 1));

            SubAttributes = new Dictionary <string, double>();

            SubAttributes.Add("Agility", 1);
            SubAttributes.Add("Toughness", 1);
            SubAttributes.Add("Cunning", 1);
            SubAttributes.Add("Wisdom", 1);
            SubAttributes.Add("Leadership", 1);
        }
    public CharacterActionState ActivateState(CharacterActionState state, Vector2 endPosition, Vector2 actionDirection)
    {
        // Все необходимые данные для выполнения действия состояния
        CharacterAction actionData = new CharacterAction(this, skillsManager, state, transform.position, endPosition, actionDirection);
        // Обработчик действия на "местности"
        CharacterActionHandler actionHandler = actionsHandlers.FirstOrDefault(handler => handler.HandledState == state);
        // Создаем экземпляр состояния из шаблона
        CharacterActionState activeState = ScriptableObject.Instantiate(state);

        activeState.InitInstance(animator, toolsManager, rotator, actionData, actionHandler);
        return(activeState);
    }
    /// <summary>
    /// Выполнение всех промежуточных состояний
    /// </summary>
    public IEnumerator Execute()
    {
        while (currentTaskPointIndex < taskPoints.Count)
        {
            PathPoint taskPoint       = taskPoints[currentTaskPointIndex];
            Vector2   axisToCharacter = taskPoint.PointPosition - taskPoint.closerToCharacterPointPosition;
            activeState = taskManager.ActivateState(taskPoint.state, taskPoint.PointPosition, axisToCharacter);
            yield return(activeState.Execute());

            currentTaskPointIndex++;
        }
    }
Exemple #17
0
 void RollingRight()
 {
     if (!IsRolling)
     {
         ActionState = CharacterActionState.NoAction;
     }
     else
     {
         Vector3 direction = playerController.transform.right * playerController.GetRollSpeed() * Time.deltaTime * playerController.GetRollDistance();
         playerController.GetCharacterController().Move(direction);
     }
 }
Exemple #18
0
    public void SetCharacterActionState(CharacterActionState newState)
    {
        if (CharacterActionState == newState)
        {
            return;
        }

        if (CharacterActionState == CharacterActionState.RoutineAction)
        {
            PlannedRoutine.InterruptRoutine();
        }

        Logger.Log(Logger.Character, "CharacterActionState of {0} set from {1} to {2}", FullName(), CharacterActionState, newState);
        CharacterActionState = newState;
    }
Exemple #19
0
 void BlockDamage()
 {
     time += Time.deltaTime;
     if (time > hitTime)
     {
         // if (playerController.canBlock)
         // {
         playerController.MyAnimator.SetBool("BlockDamaged", false);
         //      ActionState = CharacterActionState.Block;
         //  }
         //  else
         //    {
         playerController.MyAnimator.SetBool("BlockBroken", false);
         ActionState = CharacterActionState.NoAction;
         //    }
         time = 0f;
     }
 }
Exemple #20
0
    private void AddCellPoint(Vector2 pointPosition, Vector2 axis, LayerMask cellLayerMask, ref Dictionary <int, List <PathPoint> > iterationPathsByPriority)
    {
        CharacterActionState cellState = cellActionsStates.Find(state => Utils.MaskToLayer(state.actionLayerMask) == cellLayerMask);

        if (cellState != null)
        {
            if (iterationPathsByPriority.ContainsKey(cellState.priority))
            {
                iterationPathsByPriority[cellState.priority].Add(new PathPoint(cellState, pointPosition, axis));
            }
            else
            {
                iterationPathsByPriority.Add(cellState.priority, new List <PathPoint>()
                {
                    new PathPoint(cellState, pointPosition, axis)
                });
            }
        }
    }
    public void SetActionState(CharacterActionState State)
    {
        CurrentState = State;
        switch (CurrentState)
        {
        case CharacterActionState.Normal:
            GetComponent <CharacterMove>().enabled = true;
            break;

        case CharacterActionState.Charging:
            GetComponent <CharacterMove>().enabled           = false;
            GetComponent <SpeedManager>().SelfSpeedDirection = Vector3.zero;
            break;

        case CharacterActionState.ShootPreparing:
            GetComponent <CharacterMove>().enabled           = false;
            GetComponent <SpeedManager>().SelfSpeedDirection = Vector3.zero;
            break;
        }
    }
Exemple #22
0
 public void StopBlock()
 {
     ActionState = CharacterActionState.NoAction;
     IsBlocking  = false;
     playerController.MyAnimator.SetBool("Block", false);
 }
Exemple #23
0
 public void Block()
 {
     ActionState = CharacterActionState.Block;
     IsBlocking  = true;
     playerController.MyAnimator.SetBool("Block", true);
 }
Exemple #24
0
 public void Attack(int attack)
 {
     playerController.MyAnimator.SetInteger("Attack", attack);
     ActionState = CharacterActionState.Attack;
     IsAttacking = true;
 }
Exemple #25
0
 public void Slide()
 {
     ActionState = CharacterActionState.Sliding;
 }
Exemple #26
0
		public async void Load(ObjectId id) {
			var characterCollection = MongoUtils.MongoData.GetCollection<Character>("Characters", "PlayerCharacter");
			var found = await MongoUtils.MongoData.RetrieveObjectAsync<Character>(characterCollection, c => c.Id == this.Id);

			Id = found.Id;
			FirstName = found.FirstName.CamelCaseWord();
			LastName = found.LastName.CamelCaseWord();
            Build = found.Build;
            Class = found.Class;
            Race = found.Race;
            Gender = found.Gender;
            SkinType = found.SkinType;
            SkinColor = found.SkinColor;
            HairColor = found.HairColor;
            EyeColor = found.EyeColor;
            Height = found.Height;
            Weight = found.Weight;
            _stanceState = found.StanceState;
            _actionState = found.ActionState;
			Description = found.Description;
			Location = found.Location;
            Password = found.Password;
            IsNPC = found.IsNPC;
            Experience = found.Experience;
            NextLevelExperience = found.NextLevelExperience;
            Level = found.Level;
            Leveled = found.Leveled;
            PointsToSpend = found.PointsToSpend;
            MainHand = found.MainHand;
			Title = found.Title;
			KillerID = found.KillerID;

			Attributes = found.Attributes;
            Inventory = found.Inventory;
            Equipment = found.Equipment;
            Bonuses = found.Bonuses;
           
			//if (playerAttributes != null) {
			//	foreach (BsonDocument attrib in playerAttributes) {
				
			//		if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
			//			Attribute tempAttrib = new Attribute();
			//			tempAttrib.Name = attrib["Name"].ToString();
			//			tempAttrib.Value = attrib["Value"].AsDouble;
			//			tempAttrib.Max = attrib["Max"].AsDouble ;
			//			tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;
   //                     tempAttrib.Rank = attrib["Rank"].AsInt32;

			//			this.Attributes.Add(tempAttrib.Name, tempAttrib);
			//		}
			//		else {
			//			this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
   //                     this.Attributes[attrib["Name"].ToString()].Rank = attrib["Rank"].AsInt32;
			//		}
			//	}
			//}

   //         if (inventoryList.Count > 0) {
   //             foreach (BsonDocument item in inventoryList) {
   //                 IItem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
   //                 if (!Inventory.inventory.Contains(fullItem)) {
   //                     Inventory.AddItemToInventory(fullItem);
   //                 }
   //             }
   //         }

   //         if (equipmentList.Count > 0) {
   //             foreach (BsonDocument item in equipmentList) {
   //                 IItem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
   //                 if (!Equipment.equipped.ContainsKey(fullItem.WornOn)) {
   //                     Equipment.EquipItem(fullItem, this.Inventory);
   //                 }
   //             }
   //         }

   //         if (bonusesList.Count > 0) {
   //             Bonuses.LoadFromBson(bonusesList);
   //         }

			Inventory.playerID = Id;
			Equipment.playerID = Id;

		}
Exemple #27
0
 public void ActionLocked()
 {
     ActionState    = CharacterActionState.ActionLocked;
     IsActionLocked = true;
 }
Exemple #28
0
		public async void Load(ObjectId id) {
			var characterCollection = MongoUtils.MongoData.GetCollection<NPC>("Characters", "NPCCharacters");
			var found = await MongoUtils.MongoData.RetrieveObjectAsync<NPC>(characterCollection, n => n.Id == id);
            
			Id = found.Id;
			FirstName = found.FirstName.CamelCaseWord();
			LastName = found.LastName.CamelCaseWord();
            _class = found.Class;
            _race = found.Race;
            _gender = found.Gender;
            _skinType = found.SkinType;
            _skinColor = found.SkinColor;
            _hairColor = found.HairColor;
            _eyeColor = found.EyeColor;
			_stanceState = found.StanceState;
			_actionState = found.ActionState;
			Description = found.Description;
			Location = found.Location;
			Height = found.Height;
			Weight = found.Weight;
			IsNPC = found.IsNPC;
			MobTypeID = found.MobTypeID;
			NextAiAction = found.NextAiAction.ToUniversalTime();
			InCombat = found.InCombat;
			LastCombatTime = found.LastCombatTime.ToUniversalTime();
			CurrentTarget = found.CurrentTarget;
			LastTarget = found.LastTarget;
			Fsm.state = Fsm.GetStateFromName(found.AiState);
			Fsm.previousState = Fsm.GetStateFromName(found.PreviousAiState);
			Fsm.globalState = Fsm.GetStateFromName(found.AiGlobalState);
			Experience = found.Experience;
            Level = found.Level;
            Title = found.Title;
			KillerID = found.KillerID;

			Attributes = found.Attributes;
			XpTracker = found.XpTracker;
			Triggers = found.Triggers;
			Quests = found.Quests;
			Bonuses = found.Bonuses;
			StatBonus.Bonuses = Bonuses;
			
			//if (playerAttributes != null) {
			//	foreach (BsonDocument attrib in playerAttributes) {

			//		if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
			//			Attribute tempAttrib = new Attribute();
			//			tempAttrib.Name = attrib["Name"].ToString();
			//			tempAttrib.Value = attrib["Value"].AsDouble;
			//			tempAttrib.Max = attrib["Max"].AsDouble;
			//			tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;


			//			this.Attributes.Add(tempAttrib.Name, tempAttrib);
			//		}
			//		else {
			//			this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
			//		}
			//	}
			//}

			//if (xpTracker != null && xpTracker.Count > 0) {
			//	foreach (BsonDocument track in xpTracker) {
			//		//we just newed this up so it should always have to be refilled
			//		damageTracker.Add(track["ID"].AsString, track["Value"].AsDouble);
			//	}
			//}

			//foreach (BsonDocument triggerdoc in triggers) {
			//	ITrigger trigger = new GeneralTrigger(triggerdoc, TriggerType.NPC);
			//	Triggers.Add(trigger);
			//}

			//if (questIds != null) {
			//	foreach (BsonDocument questDoc in questIds) {
			//		Dictionary<string, int> playerSteps = new Dictionary<string, int>();

			//		if (questDoc.Contains("PlayerIDs")) {
			//			foreach (var playerStep in questDoc["PlayerIDs"].AsBsonArray) {
			//				playerSteps.Add(playerStep["PlayerID"].AsString, playerStep["Step"].AsInt32);
			//			}
			//		}

			//		var quest = new Quests.Quest(questDoc["QuestID"].AsString, playerSteps);

			//		if (questDoc.Contains("AutoPlayers")) {
			//			foreach (var autoID in questDoc["AutoPlayers"].AsBsonArray) {
			//				quest.AutoProcessPlayer.Enqueue(autoID.AsString);
			//			}
			//		}
					
			//		Quests.Add(quest);
			//	}
			//}

			//if (bonusesList != null && bonusesList.Count > 0) {
			//	Bonuses.LoadFromBson(bonusesList);
			//}

			Inventory.playerID = Id;
			Equipment.playerID = Id;
		}
Exemple #29
0
 public PathPoint(CharacterActionState state, Vector2 parentPosition, Vector2 axisFromParent)
 {
     this.state          = state;
     this.parentPosition = parentPosition;
     this.axisFromParent = axisFromParent;
 }
 public static bool IsActing(this ICharacterRenderProperties renderProperties, CharacterActionState action)
 {
     return(renderProperties.CurrentAction == action);
 }
Exemple #31
0
        public void Load(string id)
        {
            MongoUtils.MongoData.ConnectToDatabase();
            MongoDatabase characterDB = MongoUtils.MongoData.GetDatabase("Characters");
            MongoCollection characterCollection = characterDB.GetCollection<BsonDocument>("PlayerCharacter");
            IMongoQuery query = Query.EQ("_id", ObjectId.Parse(id));
            BsonDocument found = characterCollection.FindOneAs<BsonDocument>(query);

            ID = found["_id"].AsObjectId.ToString();
            FirstName = found["FirstName"].AsString.CamelCaseWord();
            LastName = found["LastName"].AsString.CamelCaseWord();
            _class = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord());
            _race = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord());
            _gender = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _skinColor = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _hairColor = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord());
            _eyeColor = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord());
            Height = found["Height"].AsDouble;
            Weight = found["Weight"].AsDouble;
            _stanceState = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord());
            _actionState = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord());
            Description = found["Description"].AsString;
            Location = found["Location"].AsString;
            Password = found["Password"].AsString;
            IsNPC = found["IsNPC"].AsBoolean;
            Experience = found["Experience"].AsInt64;
            NextLevelExperience = found["NextLevelExperience"].AsInt64;
            Level = found["Level"].AsInt32;
            Leveled = found["Leveled"].AsBoolean;
            PointsToSpend = found["PointsToSpend"].AsInt32;
            MainHand = found["MainHand"].AsString != "" ? found["MainHand"].AsString : null;
            Title = found.Contains("Title") ? found["Title"].AsString : "";
            KillerID = found.Contains("KillerID") ? found["KillerID"].AsString : "";

            BsonArray playerAttributes = found["Attributes"].AsBsonArray;
            BsonArray inventoryList = found["Inventory"].AsBsonArray;
            BsonArray equipmentList = found["Equipment"].AsBsonArray;
            BsonArray bonusesList = found["Bonuses"].AsBsonArray;

            if (playerAttributes != null) {
                foreach (BsonDocument attrib in playerAttributes) {

                    if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
                        Attribute tempAttrib = new Attribute();
                        tempAttrib.Name = attrib["Name"].ToString();
                        tempAttrib.Value = attrib["Value"].AsDouble;
                        tempAttrib.Max = attrib["Max"].AsDouble ;
                        tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;
                        tempAttrib.Rank = attrib["Rank"].AsInt32;

                        this.Attributes.Add(tempAttrib.Name, tempAttrib);
                    }
                    else {
                        this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Rank = attrib["Rank"].AsInt32;
                    }
                }
            }

            if (inventoryList.Count > 0) {
                foreach (BsonDocument item in inventoryList) {
                    Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
                    if (!Inventory.inventory.Contains(fullItem)) {
                        Inventory.AddItemToInventory(fullItem);
                    }
                }
            }

            if (equipmentList.Count > 0) {
                foreach (BsonDocument item in equipmentList) {
                    Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
                    if (!Equipment.equipped.ContainsKey(fullItem.WornOn)) {
                        Equipment.EquipItem(fullItem, this.Inventory);
                    }
                }
            }

            if (bonusesList.Count > 0) {
                Bonuses.LoadFromBson(bonusesList);
            }
        }
Exemple #32
0
 public void SetActionStateDouble(double state) {
     _actionState = (CharacterActionState)(int)state;
 }
Exemple #33
0
        /// <summary>
        /// Deep copy constructor
        /// </summary>
        /// <param name="copy"></param>
        public Character(Character copy) { //copy constructor
            Class = copy.Class;
            Race = copy.Race;
            Gender = copy.Gender;
            SkinColor = copy.SkinColor;
            SkinType = copy.SkinType;
            HairColor = copy.HairColor;
            EyeColor = copy.EyeColor;
            Build = copy.Build;
            _koCount = new Tuple<int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = copy._primaryLanguage;
            KnownLanguages = new HashSet<Languages>();
            foreach (Languages lang in copy.KnownLanguages) {
                KnownLanguages.Add(lang);
            }

            FirstName = copy.FirstName;
            LastName = copy.LastName;
            Description = copy.Description;
            Age = copy.Age;   //Do we want an age? And are we going to advance it every in game year?  Players could be 400+ years old rather quick.
            Weight = copy.Weight; //pounds or kilos?
            Height = copy.Height;  //inches or centimeters?
            Location = "A1000";
            InCombat = false;
            LastCombatTime = DateTime.MinValue.ToUniversalTime();
            IsNPC = false;
            Leveled = false;
            NextLevelExperience = 300;
            Level = 1;
            Experience = 0;
            PointsToSpend = 0;
            MainHand = "WIELD_RIGHT";


            Attributes = new List<Attribute>();

            foreach (var attrib in copy.Attributes){
                Attributes.Add(attrib);
            }
            
            SubAttributes = new Dictionary<string, double>();

            foreach (KeyValuePair<string, double> subAttrib in copy.SubAttributes) {
                SubAttributes.Add(subAttrib.Key, subAttrib.Value);
            }

            Inventory = new Inventory();


            this.Save();
        }
Exemple #34
0
 public void BlockDamaged()
 {
     ActionState = CharacterActionState.BlockDamaged;
     playerController.MyAnimator.SetBool("BlockDamaged", true);
     playerController.MyAnimator.SetBool("Block", false);
 }
Exemple #35
0
        public NPC(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build)
        {
            Messages = new Queue<string>();

            Fsm = AI.FSM.GetInstance();
            Fsm.state = Fsm.GetStateFromName("Wander");

            _class = characterClass;
            _race = race;
            _gender = gender;
            _skinColor = skinColor;
            _skinType = skinType;
            _hairColor = hairColor;
            _eyeColor = eyeColor;
            _build = build;

            _koCount = new Tuple<int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = language;
            KnownLanguages = new HashSet<Languages>();
            KnownLanguages.Add(_primaryLanguage);

            Inventory = new Inventory();
            damageTracker = new Dictionary<string, double>();
            Triggers = new List<ITrigger>();
            Bonuses = new StatBonuses();

            FirstName = "";
            LastName = "";
            Description = "";
            Age = 17;   //Do we want an age? And are we going to advance it every in game year?  Players could be 400+ years old rather quick.
            Weight = 180.0d; //pounds or kilos?
            Height = 70.0d;  //inches or centimeters?
            Location = "A0";
            InCombat = false;
            LastCombatTime = DateTime.MinValue.ToUniversalTime();
            IsNPC = true;
            Leveled = false;
            MainHand = "WIELD_RIGHT";
            NextLevelExperience = 300;
            Level = 1;
            Experience = 0;
            PointsToSpend = 0;
            IsMob = false;

            Inventory = new Inventory();
            Equipment = new Equipment();

            Inventory.playerID = this.ID;
            Equipment.playerID = this.ID;

            Attributes = new Dictionary<string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(200.0d, "Hitpoints", 200.0d, 0.2d, 1));
            Attributes.Add("Dexterity", new Attribute(10.0d, "Dexterity", 10.0d, 0.0d, 1));
            Attributes.Add("Strength", new Attribute(10.0d, "Strength", 10.0d, 0.0d, 1));
            Attributes.Add("Intelligence", new Attribute(10.0d, "Intelligence", 10.0d, 0.0d, 1));
            Attributes.Add("Endurance", new Attribute(10.0d, "Endurance", 10.0d, 0.0d, 1));
            Attributes.Add("Charisma", new Attribute(10.0d, "Charisma", 10.0d, 0.0d, 1));

            SubAttributes = new Dictionary<string, double>();

            SubAttributes.Add("Agility", 10.0d);
            SubAttributes.Add("Toughness", 10.0d);
            SubAttributes.Add("Cunning", 10.0d);
            SubAttributes.Add("Wisdom", 10.0d);
            SubAttributes.Add("Leadership", 10.0d);
        }
Exemple #36
0
 public void SetActionStateDouble(double state)
 {
     _actionState = (CharacterActionState)(int)state;
 }
Exemple #37
0
        public void Load(string id)
        {
            MongoUtils.MongoData.ConnectToDatabase();
            MongoDatabase characterDB = MongoUtils.MongoData.GetDatabase("Characters");
            MongoCollection characterCollection = characterDB.GetCollection<BsonDocument>("NPCCharacters");
            IMongoQuery query = Query.EQ("_id", ObjectId.Parse(id));
            BsonDocument found = characterCollection.FindOneAs<BsonDocument>(query);

            ID = found["_id"].AsObjectId.ToString();
            FirstName = found["FirstName"].AsString.CamelCaseWord();
            LastName = found["LastName"].AsString.CamelCaseWord();
            _class = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord());
            _race = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord());
            _gender = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _skinColor = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _hairColor = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord());
            _eyeColor = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord());
            _stanceState = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord());
            _actionState = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord());
            Description = found["Description"].AsString;
            Location = found["Location"].AsString;
            Height = found["Height"].AsDouble;
            Weight = found["Weight"].AsDouble;
            IsNPC = found["IsNPC"].AsBoolean;
            MobTypeID = found["MobTypeID"].AsInt32;
            NextAiAction = found["NextAiAction"].ToUniversalTime();
            InCombat = found["InCombat"].AsBoolean;
            LastCombatTime = found["LastCombatTime"].ToUniversalTime();
            CurrentTarget = found["CurrentTarget"].AsString != "" ? found["CurrentTarget"].AsString : null;
            LastTarget = found["LastTarget"].AsString != "" ? found["LastTarget"].AsString : null;
            Fsm.state = Fsm.GetStateFromName(found["AiState"].AsString);
            Fsm.previousState = Fsm.GetStateFromName(found["previousAiState"].AsString);
            Fsm.globalState = Fsm.GetStateFromName(found["AiGlobalState"].AsString);
            Experience = found["Experience"].AsInt64;
            Level = found["Level"].AsInt32;
            Title = found.Contains("Title") ? found["Title"].AsString : "";
            KillerID = found.Contains("KillerID") ? found["KillerID"].AsString : "";

            //if you just use var instead of casting it like this you will be in a world of pain and suffering when dealing with subdocuments.
            BsonArray playerAttributes = found["Attributes"].AsBsonArray;
            BsonArray xpTracker = found["XpTracker"].AsBsonArray;
            BsonDocument triggers = found["Triggers"].AsBsonDocument;
            BsonArray bonusesList = null;
            if (found.Contains("Bonuses")) {
                bonusesList = found["Bonuses"].AsBsonArray;
            }

            if (playerAttributes != null) {
                foreach (BsonDocument attrib in playerAttributes) {

                    if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
                        Attribute tempAttrib = new Attribute();
                        tempAttrib.Name = attrib["Name"].ToString();
                        tempAttrib.Value = attrib["Value"].AsDouble;
                        tempAttrib.Max = attrib["Max"].AsDouble;
                        tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;

                        this.Attributes.Add(tempAttrib.Name, tempAttrib);
                    }
                    else {
                        this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
                    }
                }
            }

            if (xpTracker != null && xpTracker.Count > 0) {
                foreach (BsonDocument track in xpTracker) {
                    //we just newed this up so it should always have to be refilled
                    damageTracker.Add(track["ID"].AsString, track["Value"].AsDouble);
                }
            }

            ITrigger trigger = new GeneralTrigger(triggers, "NPC");
            Triggers.Add(trigger);

            if (bonusesList != null && bonusesList.Count > 0) {
                Bonuses.LoadFromBson(bonusesList);
            }
        }
Exemple #38
0
 void Dead()
 {
     ActionState = CharacterActionState.Dead;
 }
Exemple #39
0
 public void SetActionState(CharacterActionState state) {
     _actionState = state;
 }
Exemple #40
0
		public Character(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build) {
			Class = characterClass;
			Race = race;
			Gender = gender;
            SkinColor = skinColor;
            SkinType = skinType;
            HairColor = hairColor;
            EyeColor = eyeColor;
            Build = build;

			_koCount = new Tuple<int, DateTime>(0, DateTime.Now);
			_actionState = CharacterActionState.None;
			_stanceState = CharacterStanceState.Standing;
            
            _primaryLanguage = language;
            KnownLanguages = new HashSet<Languages>();
            KnownLanguages.Add(_primaryLanguage);

			FirstName = "";
			LastName = "";
			Description = "";
			Age = 17;   //Do we want an age? And are we going to advance it every in game year?
			Weight = 180.0d; //pounds or kilos?
			Height = 70.0d;  //inches or centimeters?
			Location = "A1000";
			InCombat = false;
			LastCombatTime = DateTime.MinValue.ToUniversalTime();
            IsNPC = false;
            Leveled = false;
            MainHand = "WIELD_RIGHT";
            NextLevelExperience = 300;
            Level = 1;
            Experience = 0;
            PointsToSpend = 0;

            Inventory = new Inventory();
			Equipment = new Equipment();
			Bonuses = new Dictionary<BonusTypes, Bonus>();
            StatBonus = new StatBonuses();
			StatBonus.Bonuses = Bonuses;

			Inventory.playerID = Id;
			Equipment.playerID = Id;

			Attributes = new List<Attribute>();

			Attributes.Add(new Attribute(150, "Hitpoints", 150, 0.1, 1));
			Attributes.Add(new Attribute(10, "Dexterity", 5, 0, 1));
			Attributes.Add(new Attribute(10, "Strength", 5, 0, 1));
			Attributes.Add(new Attribute(10, "Intelligence", 5, 0, 1));
			Attributes.Add( new Attribute(10, "Endurance", 5, 0, 1));
			Attributes.Add(new Attribute(10, "Charisma", 5, 0, 1));

			SubAttributes = new Dictionary<string, double>();

			SubAttributes.Add("Agility", 1);
			SubAttributes.Add("Toughness", 1);
			SubAttributes.Add("Cunning", 1);
			SubAttributes.Add("Wisdom", 1);
			SubAttributes.Add("Leadership", 1);
		}