public void setValueInfo(STowerID ID, string strDescribe)
    {
        //Icon
        object[] value = PlayConfig.getBulletBuild(ID);
        SAnchor  b     = (SAnchor)value[1];

        object[] bulletData = PlayConfig.getBulletShop(ID);
        goldIcon.mainTexture     = Resources.Load <Texture>(GameConfig.PathBulletIcon + bulletData[0]);
        goldIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
        goldIcon.SetDimensions(goldIcon.mainTexture.width, goldIcon.mainTexture.height);
        goldIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

        UIAnchor anchor = goldIcon.GetComponent <UIAnchor>();

        anchor.relativeOffset = b.Anchor;
        anchor.enabled        = true;

        UIStretch stretch = goldIcon.GetComponent <UIStretch>();

        stretch.relativeSize.y = b.Stretch;
        stretch.enabled        = true;
//


        //Label
        //string[] str = PlayConfig.getBulletType(s);

        goldAbility.text = strDescribe;


        goldEffect.gameObject.SetActive(false);
    }
    public void setBulletInfo(STowerID ID, string s, GameObject bullet)
    {
        //Icon
        object[] value = PlayConfig.getBulletBuild(ID);
        SAnchor  b     = (SAnchor)value[1];

        bulletIcon.mainTexture     = Resources.Load <Texture>(GameConfig.PathBulletIcon + value[0].ToString());
        bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
        bulletIcon.SetDimensions(bulletIcon.mainTexture.width, bulletIcon.mainTexture.height);
        bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

        UIAnchor anchor = bulletIcon.GetComponent <UIAnchor>();

        anchor.relativeOffset = b.Anchor;
        anchor.enabled        = true;

        UIStretch stretch = bulletIcon.GetComponent <UIStretch>();

        stretch.relativeSize.y = b.Stretch;
        stretch.enabled        = true;

        //Label
        string[] str = PlayConfig.getBulletType(s);
        bulletAbility.text = str[0] + " TARGET";
        bulletRegion.text  = str[1];

        //Bullet effect
        if (bullet != null)
        {
            BulletController bulletController = bullet.GetComponent <BulletController>();
            if (bulletController.effect == EBulletEffect.NONE)
            {
                bulletEffect.gameObject.SetActive(false);
            }
            else
            {
                bulletEffect.gameObject.SetActive(true);
                bulletEffect.GetComponent <UIPlay>().bulletEffect = bullet;
                bulletEffect.spriteName = "icon-effect-" + bullet.GetComponent <BulletController>().effect.ToString().ToLower();
            }
            bulletEffect.GetComponent <UIPlay>().bulletEffect = bullet;
        }
    }
    public static object[] getBulletBuild(STowerID id)
    {
        SAnchor config = new SAnchor(Vector2.zero, 1);

        string s = "bullet-";

        switch (id.Type)
        {
            #region ARCHITECT
        case ETower.ARCHITECT:
            s += "architect";
            switch (id.Level)
            {
            case 1:
                config = PlayConfig.BuildBulletArchitect1;
                break;

            case 2:
                config = PlayConfig.BuildBulletArchitect2;
                break;

            case 3:
                config = PlayConfig.BuildBulletArchitect3;
                break;
            }
            break;

            #endregion
            #region ROCK
        case ETower.ROCK:
            s += "rock";
            switch (id.Level)
            {
            case 1:
                config = PlayConfig.BuildBulletRock1;
                break;

            case 2:
                config = PlayConfig.BuildBulletRock2;
                break;

            case 3:
                config = PlayConfig.BuildBulletRock3;
                break;
            }
            break;

            #endregion
            #region ICE
        case ETower.ICE:
            s += "ice";
            switch (id.Level)
            {
            case 1:
                config = PlayConfig.BuildBulletIce1;
                break;

            case 2:
                config = PlayConfig.BuildBulletIce2;
                break;

            case 3:
                config = PlayConfig.BuildBulletIce3;
                break;
            }
            break;

            #endregion
            #region FIRE
        case ETower.FIRE:
            s += "fire";
            switch (id.Level)
            {
            case 1:
                config = PlayConfig.BuildBulletFire1;
                break;

            case 2:
                config = PlayConfig.BuildBulletFire2;
                break;

            case 3:
                config = PlayConfig.BuildBulletFire3;
                break;
            }
            break;

            #endregion
            #region POISON
        case ETower.POISON:
            s += "poison";
            switch (id.Level)
            {
            case 1:
                config = PlayConfig.BuildBulletPoison1;
                break;

            case 2:
                config = PlayConfig.BuildBulletPoison2;
                break;

            case 3:
                config = PlayConfig.BuildBulletPoison3;
                break;
            }
            break;

            #endregion
            #region POISON
        case ETower.GOLD:
            s += "GOLD";
            switch (id.Level)
            {
            case 1:
                config = PlayConfig.BuildBulletGold;
                break;

            case 2:
                config = PlayConfig.BuildBulletGold;
                break;

            case 3:
                config = PlayConfig.BuildBulletGold;
                break;
            }
            break;
            #endregion
        }
        s += "-" + id.Level.ToString();
        return(new object[] { s, config });
    }
Example #4
0
    public void loadInfoTowerPassive()
    {
        if (target != null)
        {
            //AutoDestroy.destroyChildren(infoPanel, PlayNameHashIDs.Collider);

            //active tower name
            if (!labelTowerName.gameObject.activeSelf)
            {
                labelTowerName.gameObject.SetActive(true);
            }

            TowerShopController targetController = target.GetComponent <TowerShopController>();
            labelTowerName.text = targetController.Name.text.ToUpper() + " TOWER";

            //Set towe name color
            Color[] nameColor = PlayConfig.getColorTowerName(targetController.ID);
            labelTowerName.color       = nameColor[0];
            labelTowerName.effectColor = nameColor[1];

            STowerID towerID = targetController.ID;

            GameObject[] towersPassive = ObjectManager.Instance.TowersPassive;
            int          length        = towersPassive.Length;
            int          count         = 0;

            for (int i = 0; i < length; i++)
            {
                TowerPassiveController towerController = towersPassive[i].GetComponent <TowerPassiveController>();

                if (towerController.ID.Type == towerID.Type && towerController.ID.Level == towerID.Level)
                {
                    while (true)
                    {
                        GameObject info = Instantiate(towerInfoModel) as GameObject;
                        info.transform.parent     = infoPanel.transform;
                        info.transform.localScale = Vector3.one;
                        info.name = towerController.name;

                        UIAnchor anchor = info.GetComponent <UIAnchor>();
                        anchor.container      = infoPanel.gameObject;
                        anchor.relativeOffset = new Vector2(0, PlayConfig.InfoShopAnchor.PanelAnchorStart - count * PlayConfig.InfoShopAnchor.PanelAnchorDistance);

                        #region TOWER
                        TowerShopInfoController infoController = info.GetComponent <TowerShopInfoController>();
                        infoController.icon.mainTexture = Resources.Load <Texture>(PlayConfig.getTowerIcon(towerID));
                        infoController.level.text       = "Level " + ((int)towerID.Level).ToString();
                        infoController.atk.text         = towerController.attribute.MinATK.ToString() + " - " + towerController.attribute.MaxATK.ToString();
                        infoController.spawnShoot.text  = towerController.attribute.SpawnShoot.ToString();
                        infoController.timeBuild.text   = towerController.attribute.TimeBuild.ToString();

                        //Bullet label
                        string[] str = PlayConfig.getBulletType(towerController.attackType.ToString());
                        infoController.bulletAbility.text = str[0] + " TARGET";
                        infoController.bulletRegion.text  = str[1];

                        //set icon fix size
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        Vector2 localSize = new Vector2(infoController.icon.mainTexture.width, infoController.icon.mainTexture.height);
                        infoController.icon.SetDimensions((int)localSize.x, (int)localSize.y);
                        infoController.icon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch uiStretch = infoController.icon.GetComponent <UIStretch>();
                        uiStretch.enabled = true;
                        #endregion

                        #region BULLET
                        object[] bulletData      = PlayConfig.getBulletShop(towerID);
                        SAnchor  bulletTowerShop = (SAnchor)bulletData[1];
                        infoController.bulletIcon.mainTexture = Resources.Load <Texture>("Image/Bullet/Bullet Icon/" + bulletData[0].ToString());

                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free;
                        infoController.bulletIcon.SetDimensions(infoController.bulletIcon.mainTexture.width, infoController.bulletIcon.mainTexture.height);
                        infoController.bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight;

                        UIStretch stretch = infoController.bulletIcon.GetComponent <UIStretch>();
                        stretch.relativeSize.y = bulletTowerShop.Stretch;
                        stretch.enabled        = true;

                        //Add effect
                        infoController.bullet = towerController.bullet;
                        #endregion

                        count++;

                        //get Next Tower
                        if (towerController.nextLevel != null)
                        {
                            towerID         = towerController.nextLevel.GetComponent <TowerPassiveController>().ID;
                            towerController = towerController.nextLevel as TowerPassiveController;
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
	public static object[] getBulletBuild(STowerID id)
	{
        SAnchor config = new SAnchor(Vector2.zero, 1);

		string s = "bullet-";
		switch (id.Type)
		{
			#region ARCHITECT
			case ETower.ARCHITECT:
				s += "architect";
				switch (id.Level)
				{
					case 1:
						config = PlayConfig.BuildBulletArchitect1;
						break;
					case 2:
						config = PlayConfig.BuildBulletArchitect2;
						break;
					case 3:
						config = PlayConfig.BuildBulletArchitect3;
						break;
				}
				break;
			#endregion
			#region ROCK
			case ETower.ROCK:
				s += "rock";
				switch (id.Level)
				{
					case 1:
						config = PlayConfig.BuildBulletRock1;
						break;
					case 2:
						config = PlayConfig.BuildBulletRock2;
						break;
					case 3:
						config = PlayConfig.BuildBulletRock3;
						break;
				}
				break;
			#endregion
			#region ICE
			case ETower.ICE:
				s += "ice";
				switch (id.Level)
				{
					case 1:
						config = PlayConfig.BuildBulletIce1;
						break;
					case 2:
						config = PlayConfig.BuildBulletIce2;
						break;
					case 3:
						config = PlayConfig.BuildBulletIce3;
						break;
				}
				break;
			#endregion
			#region FIRE
			case ETower.FIRE:
				s += "fire";
				switch (id.Level)
				{
					case 1:
						config = PlayConfig.BuildBulletFire1;
						break;
					case 2:
						config = PlayConfig.BuildBulletFire2;
						break;
					case 3:
						config = PlayConfig.BuildBulletFire3;
						break;
				}
				break;
			#endregion
            #region POISON
            case ETower.POISON:
                s += "poison";
                switch (id.Level)
                {
                    case 1:
                        config = PlayConfig.BuildBulletPoison1;
                        break;
                    case 2:
                        config = PlayConfig.BuildBulletPoison2;
                        break;
                    case 3:
                        config = PlayConfig.BuildBulletPoison3;
                        break;
                }
                break;
            #endregion
			#region POISON
		case ETower.GOLD:
			s += "GOLD";
			switch (id.Level)
			{
			case 1:
				config = PlayConfig.BuildBulletGold;
				break;
			case 2:
				config = PlayConfig.BuildBulletGold;
				break;
			case 3:
				config = PlayConfig.BuildBulletGold;
				break;
			}
			break;
			#endregion
		}
		s += "-" + id.Level.ToString();
		return new object[] { s, config };
	}