예제 #1
0
        public int _locationID;                                //location ID where the person is currently located

        #endregion

        #region Constructor

        public Character()
        {
            _name      = "";
            _id        = 0;
            _fame      = 0;
            _age       = 0;
            _jobID     = -1;
            _mindset   = new CharacterMindset();
            _bodyneeds = new CharacterBodyNeeds();
            _currentActionFinishTime = new Gametime(0, 0, 0);
            _health                   = new CharacterHealth();
            _characterActions         = new characterActionPriorityQueue();     //the list of actions the character wants to do
            _characterPreviousActions = new List <actionHistory>();
            _characterinventory       = new CharacterInventory();
            _locationID               = Consts.stronghold_yard;
            _homeID                   = Consts.stronghold_yard;

            //eating events
            _bodyneeds._hungryEvent += this.OnHungryEventHandler;             //hungry event listener

            //determining gender 50-50
            if (Consts.rand.Next(1, 1000) > 500)
            {
                _gender = Gender.Male;
            }
            else
            {
                _gender = Gender.Female;
            }
        }
 public void Clone(characterActionPriorityQueue target)
 {
     //Consts.writeEnteringMethodToDebugLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
     this.Clear();
     foreach (CharacterAction val in target)
     {
         this.Enqueue(val);
     }
     //Consts.writeExitingMethodToDebugLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
 }
        public void insertItemIntoQueue(CharacterAction newItem)
        {
            //Consts.writeEnteringMethodToDebugLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            characterActionPriorityQueue temp = new characterActionPriorityQueue();
            bool flag = false;

            if (this.Count == 0)
            {
                this.Enqueue(newItem);
            }
            else
            {
                foreach (CharacterAction queueItem in this)
                {
                    if (!flag)                     //new item is not inserted yet
                    {
                        if (queueItem.Priority >= newItem.Priority)
                        {
                            temp.Enqueue(newItem);
                            temp.Enqueue(queueItem);
                            flag = true;
                        }
                        else
                        {
                            temp.Enqueue(queueItem);
                        }
                    }
                    else
                    {
                        temp.Enqueue(queueItem);
                    }
                }
                if (!flag)
                {
                    temp.Enqueue(newItem);                     //if flag remains false then newItem has highest priority
                }
                this.Clone(temp);
            }
            //Consts.writeExitingMethodToDebugLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
        }        //inserts item into queue based on priority