Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        private void EndLoop(int reason)
        {
            Character.Dispatch(WorldMessage.CRAFT_LOOP_END(reason));

            base.RemoveTimer(m_loopTimer);
            m_loopTimer = null;
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="skill"></param>
        private void Harvest(CharacterEntity character, SkillIdEnum skill)
        {
            if (!character.CanGameAction(GameActionTypeEnum.SKILL_HARVEST))
            {
                character.Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_YOU_ARE_AWAY));
                return;
            }

            if (!IsActive)
            {
                return;
            }

            m_currentJob = character.CharacterJobs.GetJob(skill);
            if (m_currentJob == null)
            {
                return;
            }

            var duration = m_currentJob.HarvestDuration;

            m_quantityFarmed = Util.Next(m_currentJob.HarvestMinQuantity, m_currentJob.HarvestMaxQuantity);

            character.HarvestStart(this, duration);
            m_currentHarvester = character;

            Deactivate();

            m_harvestTimer = base.AddTimer(duration, StopHarvest, true);
        }
 public override void Remove(float delay)
 {
     _handler.IsPlaying = false;
     updatables.Clear();
     GameObject.Destroy(_handler.gameObject);
     _handler = null;
     base.Remove(delay);
 }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="count"></param>
        public void Retry(int count)
        {
            if (m_loopTimer != null)
            {
                return;
            }

            m_loopCount = count;
            m_loopTimer = base.AddTimer(1100, Loop);
        }
    public override void Init()
    {
        Debug.Log("Init UpdatableModuleBase");

        updatables = new List <IUpdatable>();
        base.Init();
        GameObject obj = new GameObject();

        obj.name = "UpdatableTimer";
        //GameObject.Instantiate(obj);
        _handler = obj.AddComponent <UpdatableTimer>();
        _handler.Init(Update);
    }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        public MonsterGroupEntity(long id, int mapId, int cellId, IEnumerable <MonsterSpawnDAO> monsters, int maxSize = 6)
            : this(id, mapId, cellId)
        {
            var size = 1;

            if (monsters.All(monster => monster.Probability == 1))
            {
                size = monsters.Count();
            }
            else
            {
                var rand = Util.Next(0, 100);
                if (rand < 10) // 10%
                {
                    size = 1;
                }
                else if (rand < 25)
                {
                    size = 2;
                }
                else if (rand < 50)
                {
                    size = 3;
                }
                else if (rand < 75)
                {
                    size = 4;
                }
                else if (rand < 90)
                {
                    size = 5;
                }
                else
                {
                    size = 6;
                }
            }

            if (size > maxSize)
            {
                size = maxSize;
            }

            if (monsters.Count() > 0)
            {
                while (m_monsters.Count < size)
                {
                    foreach (var spawn in monsters)
                    {
                        if (AlignmentId == -2 || spawn.Grade.Template.Alignment == AlignmentId)
                        {
                            var chance = Util.Next(0, 100);
                            if (chance < spawn.Probability * 100)
                            {
                                m_monsters.Add(new MonsterEntity(m_nextMonsterId--, spawn.Grade));

                                if (AlignmentId == -2)
                                {
                                    AlignmentId = spawn.Grade.Template.Alignment;
                                }

                                if (m_monsters.Count == size)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                AggressionRange = m_monsters.Max(monster => monster.Grade.Template.AggressionRange);
            }

            base.AddTimer(m_ageTimer = new UpdatableTimer(1000 * WorldConfig.PVM_STAR_BONUS_PERCENT_SECONDS, UpdateAge));
        }