Пример #1
0
        public Dwarf(Vector3 position, LivingType type)
            : base(position, type)
        {
            TimeWorked = 0;
            Stats = new DwarfStats(this);
            Stats.SetStartValues();

            HealthPoints = 100;
            if (Id == 0)
                _texture = WorldMap.Instance.GetContent().Load<Texture2D>("dwarf");
            else
                _texture = WorldMap.Instance.GetContent().Load<Texture2D>("dwarf2");

            _noToolTexture = WorldMap.Instance.GetContent().Load<Texture2D>("hammerSymbol");
            _noFoodTexture = WorldMap.Instance.GetContent().Load<Texture2D>("hungrySymbol");
            _font = WorldMap.Instance.GetContent().Load<BitmapFont>("Fonts/pressStart2P");
            _ai = new DwarfAi();

            #if DEBUG_WINDOW
            if (type == LivingType.Dwarf)
                DebugWindow.Instance.RegisterDwarf(this);
            #endif
            if (type == LivingType.Dwarf)
            {
                PrioritySystem.AddDwarf();
                Name = RandomNameGenerator.GenerateName();
            }
        }
Пример #2
0
        private void PutAnimalsInPasture(LivingType type)
        {
            List<Animal> animals = WorldMap.Instance.GetAllFreeAnimal(type);

            if (animals.Count > 0)
            {
                foreach (Animal animal in animals)
                {
                    if (_pasture.Capacity > _pasture.GetAnimalsInPasture().Count)
                    {
                        animal.PutInPasture(_pasture);
                        _pasture.AddAnimal(animal);
                    }
                }
            }
            else
            {
                List<PastureSim> pastures = SimulationWorld.Instance.GetPastures();

                foreach (PastureSim p in pastures)
                {
                    if (p.GetAnimalsInPasture().Count > 0 && p.GetAnimalsInPasture()[0].Type == type)
                    {
                        Animal a = p.TakeAnimal();
                        a.PutInPasture(_pasture);
                        _pasture.AddAnimal(a);
                    }
                }
            }
        }
Пример #3
0
 public Living(Vector3 position, LivingType type)
 {
     Type = type;
     CollisionRadius = 0.5f;
     _moveCounter = 0;
     MovePath = new Stack<Point>();
     Position = position;
     Id = _idCounter;
     _idCounter++;
 }
Пример #4
0
        public Minion(Vector3 position, LivingType type, AmorType amorType, bool isAmored, float amorDurability)
            : base(position, type)
        {
            AmorType = amorType;
            IsAmored = isAmored;
            _amorDurability = amorDurability;

            _ai = new MinionAi(this);

            _healthBar = WorldMap.Instance.GetContent().Load<Texture2D>("healthBar");
            _health = WorldMap.Instance.GetContent().Load<Texture2D>("health");
        }
Пример #5
0
        public Dwarf(Vector3 position, LivingType type)
            : base(position, type)
        {
            TimeWorked = 0;
            Stats = new DwarfStats();
            Stats.SetStartValues();
            HealthPoints = 100;
            if (Id == 0)
            _texture = WorldMap.Instance.GetContent().Load<Texture2D>("dwarf");
            else
                _texture = WorldMap.Instance.GetContent().Load<Texture2D>("dwarf2");
            _ai = new DwarfAi();

            Speed = 0.005f;
        }
Пример #6
0
        public List<Animal> GetAllFreeAnimal(LivingType type)
        {
            List<Animal> animal = new List<Animal>();

            foreach (Living l in _creatures)
            {
                if (l.Type == type)
                {
                    Animal p = (Animal)l;
                    if (p.Pasture == null)
                        animal.Add(p);
                }
            }

            return animal;
        }
Пример #7
0
 public Animal(Vector3 position, LivingType type)
     : base(position, type)
 {
     _ai = new AnimalAi();
 }
Пример #8
0
    void onPlayerDataChange(NetworkMessage message)
    {
        byte count = message.readUInt8();

        for (int i = 0; i < count; i++)
        {
            LivingType type = (LivingType)message.readUInt8();
            switch (type)
            {
            case LivingType.has_email:    //x有信息
                Player.Instance.HaveEmail = message.readBool();
                DzViewMain.Instance.InitInviteClubMessage();

                break;

            case LivingType.clubInviteChange:    //邀请列表变化
                int Messagecount = message.readInt32();
                GameData.InviteClubIdAndName = new List <ClubInfo>();
                for (int j = 0; j < Messagecount; j++)
                {
                    ClubInfo info = new ClubInfo();
                    info.Id       = (int)message.readUInt32();
                    info.ClubName = message.readString();
                    GameData.InviteClubIdAndName.Add(info);
                }
                if (ClubInvitePanelControl.Instance == null)
                {
                    UIManager.Instance.ShowUiPanel(UIPaths.ClubInvitePlayerPanel);
                }
                else
                {
                    if (ClubInvitePanelControl.Instance.gameObject.activeSelf)
                    {
                        ClubInvitePanelControl.Instance.InitData();
                    }
                    else
                    {
                        UIManager.Instance.ShowUiPanel(UIPaths.ClubInvitePlayerPanel);
                    }
                }
                break;

            case LivingType.card:
                Player.Instance.RoomCard = message.readInt64();
                break;

            case LivingType.otherName:
                break;

            case LivingType.headId:
                break;

            case LivingType.gold:
                Player.Instance.Gold = message.readInt64();
                break;

            case LivingType.diamond:
                Player.Instance.money = message.readInt64();
                break;

            case LivingType.clubChange:           //俱乐部信息改变
                GameData.PKClubInfoList = new List <PkClubInfo>();
                int count1 = message.readInt32(); //俱乐部个数
                for (int j = 0; j < count1; j++)
                {
                    PkClubInfo info = new PkClubInfo();
                    info.ClubId   = message.readUInt32(); //clubid
                    info.ClubName = message.readString(); //俱乐部名字
                    message.readString();                 //者的名字
                    message.readInt32();                  //俱乐部玩家个数

                    info.RoomCount = 0;
                    GameData.PKClubInfoList.Add(info);
                }

                DzViewMain.Instance.CreatPkClubList();
                break;
            }
        }

        GameEventDispatcher.Instance.dispatchEvent(EventIndex.PlayerLivingDataChange);//玩家数据改变
    }