Esempio n. 1
0
    void ClearEvt()
    {
        ConstructionItem cItem = null;

        for (int i = 0; i < itemPool_.Count; ++i)
        {
            cItem = itemPool_[i].GetComponent <ConstructionItem>();
            UIEventListener.Get(cItem.lvbtn_.gameObject).onClick -= OnClickItem;
        }
    }
    protected override void Awake() {
        //base.Awake();

        meshRender = transform.parent.GetComponent<MeshRenderer>();

        physicalCollider = GetComponent<Collider>();

        connectedObject = transform.root;
        constructControl = connectedObject.GetComponent<ConstructionItem>();
    }
Esempio n. 3
0
    public void Display(ConstructionItem item, GameObject dragParent, GameObject originalParent)
    {
        this.item   = item;
        Icon.sprite = item.sprite;
        Vector2 size = new Vector2(item.sprite.bounds.size.x, item.sprite.bounds.size.y);

        Icon.rectTransform.sizeDelta = size * 100;
        ItemName.text       = item.name;
        this.dragParent     = dragParent;
        this.originalParent = originalParent;
    }
Esempio n. 4
0
 internal void BuyItem(ConstructionItem item, Vector2 spawnPosition)
 {
     Debug.Log("Bought item:" + item.name);
     if (item.Price <= money)
     {
         money -= item.Price;
         // ConstructionItem newitem= Instantiate(item,spawnPosition,Quaternion.identity);
         // item.levelManager=this;
         // items.Add(item);
     }
     RefreshMoney();
 }
Esempio n. 5
0
 public void OnEndDrag(PointerEventData data)
 {
     if (!IsMouseOverUi())
     {
         Vector3 objpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         objpos.z = 0;
         ConstructionItem newitem = Instantiate(shopSlot.item, objpos, Quaternion.identity);
         // newitem.levelManager=
         shopSlot.Icon.transform.localPosition = Vector3.zero;
     }
     else
     {
         shopSlot.Icon.transform.localPosition = Vector3.zero;
     }
 }
Esempio n. 6
0
        public override void Execute(Level level)
        {
            ClientAvatar avatar = level.GetPlayerAvatar();

            foreach (var buildingId in BuildingIds)
            {
                ConstructionItem gameObjectById = (ConstructionItem)level.GameObjectManager.GetGameObjectByID(buildingId);
                int diamondCount = ((BuildingData)gameObjectById.GetConstructionItemData()).BoostCost[gameObjectById.UpgradeLevel];
                if (avatar.HasEnoughDiamonds(diamondCount))
                {
                    gameObjectById.BoostBuilding();
                    avatar.SetDiamonds(avatar.GetDiamonds() - diamondCount);
                }
            }
        }
Esempio n. 7
0
        public override void Execute(Level level)
        {
            ClientAvatar ca = level.GetPlayerAvatar();

            foreach (int buildingId in BuildingIds)
            {
                GameObject       go = level.GameObjectManager.GetGameObjectByID(buildingId);
                ConstructionItem b  = (ConstructionItem)go;
                int costs           = ((BuildingData)b.GetConstructionItemData()).BoostCost[b.UpgradeLevel];
                if (ca.HasEnoughDiamonds(costs))
                {
                    b.BoostBuilding();
                    ca.SetDiamonds(ca.GetDiamonds() - costs);
                }
            }
        }
Esempio n. 8
0
        internal override void Process()
        {
            ClientAvatar ca = this.Device.Player.Avatar;

            foreach (int buildingId in BuildingIds)
            {
                GameObject       go = this.Device.Player.GameObjectManager.GetGameObjectByID(buildingId);
                ConstructionItem b  = (ConstructionItem)go;
                int costs           = ((BuildingData)b.GetConstructionItemData()).BoostCost[b.UpgradeLevel];
                if (ca.HasEnoughDiamonds(costs))
                {
                    b.BoostBuilding();
                    ca.m_vCurrentGems = ca.m_vCurrentGems - costs;
                }
            }
        }
Esempio n. 9
0
        public Combat_Component(ConstructionItem ci) : base(ci)
        {
            this.Item = ci;

            if (ci.ClassId == 4 || ci.ClassId == 11)
            {
                var td = (Traps)ci.Data;
                if (td.HasAltMode)
                {
                    this.AltTrapAttackMode = true;
                }

                if (td.DirectionCount > 0)
                {
                    this.AltDirectionMode = true;
                }
            }
            else if (ci.ClassId == 0 || ci.ClassId == 7)
            {
                var bd = (Buildings)ci.Data;

                if (bd.AmmoCount > 0)
                {
                    this.Ammo = bd.AmmoCount;
                }

                if (bd.AltAttackMode)
                {
                    this.AltAttackMode = true;
                }

                if (bd.AimRotateStep > 0)
                {
                    this.AimRotateStep = true;
                }

                if (bd.VillageType != null)
                {
                    _ = this.ActiveVillage2Layout >= 0;
                }

                else
                {
                    _ = this.ActiveLayout >= 0;
                }
            }
        }
Esempio n. 10
0
    void OnFamilyDataEvent(int num)
    {
        ConstructionItem cItem = null;

        for (int i = 0; i < itemPool_.Count; ++i)
        {
            cItem = itemPool_[i].GetComponent <ConstructionItem>();
            if (cItem != null)
            {
                cItem.UpdataInfo();
            }
        }

        if (detail_.gameObject.activeSelf)
        {
            detail_.SetData(detail_.data_.id_);
            EffectAPI.PlayUIEffect((EFFECT_ID)GlobalValue.EFFECT_familyLevelUp, detail_.transform, () => {});
        }
    }
        public override void Execute(Level level)
        {
            ClientAvatar avatar         = level.GetPlayerAvatar();
            GameObject   gameObjectById = level.GameObjectManager.GetGameObjectByID(BuildingId);

            if (gameObjectById == null)
            {
                return;
            }

            ConstructionItem constructionItem = (ConstructionItem)gameObjectById;

            if (!constructionItem.CanUpgrade())
            {
                return;
            }

            ConstructionItemData constructionItemData = constructionItem.GetConstructionItemData();

            if (!avatar.HasEnoughResources(constructionItemData.GetBuildResource(constructionItem.GetUpgradeLevel() + 1), constructionItemData.GetBuildCost(constructionItem.GetUpgradeLevel() + 1)) || !level.HasFreeWorkers())
            {
                return;
            }

            string name = level.GameObjectManager.GetGameObjectByID(BuildingId).GetData().GetName();

            Logger.Write("Building To Upgrade : " + name + " (" + BuildingId + ')');
            if (string.Equals(name, "Alliance Castle"))
            {
                avatar.IncrementAllianceCastleLevel();
                BuildingData buildingData = ((Building)level.GameObjectManager.GetGameObjectByID(BuildingId)).GetBuildingData();
                avatar.SetAllianceCastleTotalCapacity(buildingData.GetUnitStorageCapacity(avatar.GetAllianceCastleLevel()));
            }
            else if (string.Equals(name, "Town Hall"))
            {
                avatar.IncrementTownHallLevel();
            }

            ResourceData buildResource = constructionItemData.GetBuildResource(constructionItem.GetUpgradeLevel() + 1);

            avatar.SetResourceCount(buildResource, avatar.GetResourceCount(buildResource) - constructionItemData.GetBuildCost(constructionItem.GetUpgradeLevel() + 1));
            constructionItem.StartUpgrading();
        }
Esempio n. 12
0
        public override void Execute(Level level)
        {
            ClientAvatar ca = level.GetPlayerAvatar();
            GameObject   go = level.GameObjectManager.GetGameObjectByID(BuildingId);

            ConstructionItem b = (ConstructionItem)go;

            if (b.CanUpgrade())
            {
                var bd = b.GetConstructionItemData();
                if (ca.HasEnoughResources(bd.GetBuildResource(b.GetUpgradeLevel() + 1), bd.GetBuildCost(b.GetUpgradeLevel() + 1)))
                {
                    if (level.HasFreeWorkers())
                    {
                        ResourceData rd = bd.GetBuildResource(b.GetUpgradeLevel() + 1);
                        ca.SetResourceCount(rd, ca.GetResourceCount(rd) - bd.GetBuildCost(b.GetUpgradeLevel() + 1));
                        b.StartUpgrading();
                    }
                }
            }
        }
Esempio n. 13
0
    // Update is called once per frame
    void Update()
    {
        if (Building)
        {
            BuildingPhase(ConstructionLine);
        }
        else
        {
            NotBuildingPhase(ConstructionLine);
        }

        if (Input.GetKeyDown(CancelConstruction))
        {
            ConsType = ConstructionItem.NULL;
            Building = false;
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            CanBuild = !CanBuild;
        }
    }
        public override void Execute(Level level)
        {
            ClientAvatar     avatar               = level.GetPlayerAvatar();
            ConstructionItem gameObjectById       = (ConstructionItem)level.GameObjectManager.GetGameObjectByID(BuildingId);
            BuildingData     constructionItemData = (BuildingData)gameObjectById.GetConstructionItemData();

            if (!avatar.HasEnoughResources(constructionItemData.GetBuildResource(gameObjectById.GetUpgradeLevel()), constructionItemData.GetBuildCost(gameObjectById.GetUpgradeLevel())))
            {
                return;
            }
            string name = level.GameObjectManager.GetGameObjectByID(BuildingId).GetData().GetName();

            Logger.Write("Unlocking Building: " + name + " (" + BuildingId + ')');
            if (string.Equals(name, "Alliance Castle"))
            {
                avatar.IncrementAllianceCastleLevel();
                BuildingData buildingData = ((Building)level.GameObjectManager.GetGameObjectByID(BuildingId)).GetBuildingData();
                avatar.SetAllianceCastleTotalCapacity(buildingData.GetUnitStorageCapacity(avatar.GetAllianceCastleLevel()));
            }
            ResourceData buildResource = constructionItemData.GetBuildResource(gameObjectById.GetUpgradeLevel());

            avatar.SetResourceCount(buildResource, avatar.GetResourceCount(buildResource) - constructionItemData.GetBuildCost(gameObjectById.GetUpgradeLevel()));
            gameObjectById.Unlock();
        }
Esempio n. 15
0
 void Start()
 {
     terrainCollider = GameObject.Find("Terrain").GetComponent <Collider>();
     db        = GetComponent <ConstructionDB>();
     buildItem = db.buildings[0];
 }
Esempio n. 16
0
 public EndMovementCommand(List <ConstructionItem> neighbors, ConstructionItem item)
 {
     this.item      = item;
     this.neighbors = neighbors;
 }
Esempio n. 17
0
 public RotateItemsRightCommand(List <ConstructionItem> neighbors, ConstructionItem item)
 {
     this.item      = item;
     this.neighbors = neighbors;
 }
Esempio n. 18
0
 public ActionResult create(ConstructionItem constructionitem)
 {
     _context.ConstructionItems.Add(constructionitem);
     _context.SaveChanges();
     return(RedirectToAction("AddNewItem", "AddOrder"));
 }