Exemple #1
0
        public void setState(int level, int size, int id)
        {
            this.level = level;
            this.size  = size;
            this.id    = id;
            layRoad();
            buildBuildings();

            this.attribute    = TownAttributeMasterManager.getInstance().getRandomAttribute();
            priseMag          = attribute.getPriseMag() * UnityEngine.Random.Range(0.8f, 1.2f) + (level - size) / 100;
            this.attributeMag = attribute.getAttributeMags();

            observer = new TownObserver(this);
        }
Exemple #2
0
        public void setState(TownBuilder builder)
        {
            gameObject.transform.position = builder.Position;
            gameObject.transform.rotation = builder.Quaternion;

            this.direction = builder.Direction;
            layRoad();

            this.id            = builder.Id;
            this.level         = builder.Level;
            this.size          = builder.Size;
            this.priseMag      = builder.PriseMag;
            this.clients       = builder.Clients;
            this.merchants     = builder.Merchants;
            this.citizens      = builder.Citizens;
            this.attributeMag  = builder.AttributeMag;
            this.grid          = builder.Grid;
            this.buildingDatas = builder.BuildingDatas;

            this.attribute = TownAttributeMasterManager.getInstance().getTownAttributeFromId(builder.TownAttributeId);

            Debug.Log("attributeMag count " + attributeMag.Count);

            foreach (var buildingData in buildingDatas)
            {
                var building = buildingData.restore();
                buildings.Add(building);
                building.transform.SetParent(transform);
            }

            characters.AddRange(citizens);

            foreach (Merchant merchant in merchants)
            {
                merchant.setTown(this);
            }
            characters.AddRange(merchants);

            characters.AddRange(clients);

            foreach (IFriendly friendlyCharacter in characters)
            {
                friendlyCharacter.getContainer().transform.SetParent(transform);
            }

            observer = new TownObserver(this);
        }