private GameObject makeFireButton(int i) { Rect fightButtonRect = new Rect(760,375,buttonSize.x, buttonSize.y); //fightButtonRect = FindPos(numButtons, fightButtonRect); GameObject fight = MakeButton("Fight",fightButtonRect); fight.AddComponent("Menu"); fight.AddComponent ("FireAction"); fight.GetComponent<FireAction>().fightMenu = fight.GetComponent<Menu>(); fight.AddComponent ("WeaponAnimator"); WeaponAnimator fightWA = fight.GetComponent<WeaponAnimator>(); fightWA.hitParticle = hitp; fightWA.ballistaFire = balfire; fightWA.ballistaHit = balhit; fightWA.catapultFire = trefire; fightWA.catapultHit = trehit; fightWA.cannonFire = canfire; fightWA.cannonHit = canhit; fightWA.missSound = miss; fightWA.missFont = missfont; fightWA.splitScreenTexture = splitscreen; fightWA.damageText = damagetext; fight.AddComponent ("CollapseAnimator"); CollapseAnimator fightCA = fight.GetComponent<CollapseAnimator>(); fightCA.collapseParticle = collp; fightCA.soundEffect = sound; fight.AddComponent<AudioSource>(); fight.transform.parent = transform; m2 = fight.GetComponent<MenuItem>(); m2.action = fight.GetComponent<FireAction>(); m2.tooltipSkin = squareStyle; m2.SetTooltipLabel(false); m2.tooltip = "Click Fight to attack enemy towers."; m2.tooltipHeight = 75; m2.tooltipWidth = 100; m2.tooltipLeftRel = -105; m2.tooltipTopRel = 0; //m2.guiSkin = squareStyle; m2.action.click = click; menuItems.Add(m2); return fight; }
public override void Update() { if(hasLoaded) { m1.tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); m1.tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height)); m2.tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); m2.tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height)); m3.tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); m3.tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height)); m4.tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); m4.tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height)); m5.tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); m5.tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height)); } if(!hasLoaded) { Rect buildButtonRect = new Rect(760,(435) + ((numButtons-1) *(150/(numButtons))) ,190, (150/(2))); build = MakeButton("Build",buildButtonRect); build.AddComponent("SwitchMenu"); build.AddComponent ("BuildMenu"); SwitchMenu buildSM = build.GetComponent<SwitchMenu>(); BuildMenu buildBM = build.GetComponent<BuildMenu>(); build.transform.parent = transform; m1 = build.GetComponent<MenuItem>(); m1.action = buildSM; m1.guiSkin = squareStyle; m1.tooltipSkin = squareStyle; m1.SetTooltipLabel(false); m1.tooltip = "Click here to build a tower section on the selected tower."; m1.tooltipHeight = 75; m1.tooltipWidth = 100; m1.tooltipLeftRel = -105; m1.tooltipTopRel = 0; //m1.setTooltipOn(false); buildSM.fromMenu = this.gameObject; buildSM.toMenu = build; buildBM.click = click; buildBM.squareStyle = squareStyle; m1.action.click = click; menuItems.Add(m1); numButtons++; fight = makeFireButton(numButtons); Rect fortifyButtonRect = new Rect(760,255,buttonSize.x, buttonSize.y); //fortifyButtonRect = FindPos(numButtons, fortifyButtonRect); fortify = MakeButton("Fortify",fortifyButtonRect); fortify.AddComponent("SwitchMenu"); fortify.AddComponent ("FortifyMenu"); SwitchMenu fortifySM = fortify.GetComponent<SwitchMenu>(); FortifyMenu fortifyFM = fortify.GetComponent<FortifyMenu>(); fortify.transform.parent = transform; m3 = fortify.GetComponent<MenuItem>(); m3.action = fortifySM; m3.guiSkin = squareStyle; m3.tooltipSkin = squareStyle; m3.SetTooltipLabel(false); m3.tooltip = "Fortify sections to add health to them."; m3.tooltipHeight = 75; m3.tooltipWidth = 100; m3.tooltipLeftRel = -105; m3.tooltipTopRel = 0; fortifySM.fromMenu = this.gameObject; fortifySM.toMenu = fortify; fortifyFM.click = click; fortifyFM.squareStyle = squareStyle; m3.action.click = click; menuItems.Add(m3); Rect upgradeButtonRect = new Rect(760,315,buttonSize.x, buttonSize.y); //upgradeButtonRect = FindPos(numButtons, upgradeButtonRect); upgrade = MakeButton("Upgrade",upgradeButtonRect); upgrade.AddComponent("SwitchMenu"); upgrade.AddComponent ("UpgradeMenu"); SwitchMenu upgradeSM = upgrade.GetComponent<SwitchMenu>(); UpgradeMenu upgradeUM = upgrade.GetComponent<UpgradeMenu>(); upgrade.transform.parent = transform; m4 = upgrade.GetComponent<MenuItem>(); m4.action = upgradeSM; m4.guiSkin = squareStyle; m4.tooltipSkin = squareStyle; m4.SetTooltipLabel(false); m4.tooltip = "Upgrade adds special effects to weapons."; m4.tooltipHeight = 75; m4.tooltipWidth = 100; m4.tooltipLeftRel = -105; m4.tooltipTopRel = 0; upgradeSM.fromMenu = this.gameObject; upgradeSM.toMenu = upgrade; upgradeUM.click = click; upgradeUM.squareStyle = squareStyle; m4.action.click = click; menuItems.Add(m4); Rect passButtonRect = new Rect(760,(435) + ((numButtons-1) *(150/(numButtons)))+10,190,150/(2)); GameObject pass = MakeButton("Pass",passButtonRect); pass.AddComponent("PassAction"); pass.transform.parent = transform; m5 = pass.GetComponent<MenuItem>(); m5.action = pass.GetComponent<PassAction>(); m5.action.click = click; m5.tooltipSkin = squareStyle; m5.SetTooltipLabel(false); m5.tooltip = "Click to use an action and pass."; m5.tooltipHeight = 75; m5.tooltipWidth = 100; m5.tooltipLeftRel = -105; m5.tooltipTopRel = 0; menuItems.Add(m5); numButtons++; hasLoaded = true; } base.Update(); if(TowerSelection.GetSelectedSection() == null) { fight.GetComponent<MenuItem>().visible = false; } else if (TowerSelection.GetSelectedSection() != null && (TowerSelection.GetSelectedSection().GetWeaponInfo() == "Nothing" || TurnOrder.ceasefire > TurnOrder.turnNum)) { fight.GetComponent<MenuItem>().visible = false; } else { fight.GetComponent<MenuItem>().visible = true; } if(TowerSelection.GetSelectedSection() == null) { upgrade.GetComponent<MenuItem>().visible = false; } else if(TowerSelection.GetSelectedSection() != null && TowerSelection.GetSelectedSection().attributes.weapon.GetUpgradeLevel() >= TowerSelection.GetSelectedSection().attributes.weapon.maxUpgradeLevel) { upgrade.GetComponent<MenuItem>().visible = false; } else { upgrade.GetComponent<MenuItem>().visible = true; } if(TowerSelection.GetSelectedSection() == null) { fortify.GetComponent<MenuItem>().visible = false; } else if(TowerSelection.GetSelectedSection() != null && TowerSelection.GetSelectedSection().attributes.sp >= TowerSelection.GetSelectedSection().attributes.maxSP) { fortify.GetComponent<MenuItem>().visible = false; } else { fortify.GetComponent<MenuItem>().visible = true; } //Don't allow player to build if Tower is not alive if(TowerSelection.GetSelectedTower() == null || TowerSelection.GetSelectedTower().isAlive() == false) { build.GetComponent<MenuItem>().visible = false; }else { build.GetComponent<MenuItem>().visible = true; } }
public override void Update() { ValueStore.selectedMaterial = sm; foreach(BuildConfirmMenu b in this.gameObject.GetComponentsInChildren<BuildConfirmMenu>()) { b.sm = ValueStore.selectedMaterial; b.sw = ValueStore.selectedWeapon; } if(hasLoaded) { /*m1.tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); m1.tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height));*/ Tower t = TowerSelection.GetSelectedTower(); for(int i=0; i<Faction.NUM_WEAPONS; i++) { string text = t.faction.weapons[i]; weaponButtons[i].text = text + ": $" + SectionComponentFactory.GetWeapon(text).cost; weaponButtons[i].GetComponent<WeaponCostLabelUpdate>().weaponName = text; weaponButtons[i].tooltip = "Damage: " + SectionComponentFactory.GetWeapon(text).GetDamage() + "\nRange: " + SectionComponentFactory.GetWeapon(text).GetRange() + "\nWeight: " + SectionComponentFactory.GetWeapon(text).GetWeight(); weaponButtons[i].tooltipLeftRel = (Input.mousePosition.x * (960f/Screen.width)); weaponButtons[i].tooltipTopRel = (600) - ((Input.mousePosition.y) * (600f/Screen.height)); } } if(!hasLoaded) { this.guiSkin = squareStyle; GameObject values = new GameObject("BuildValues"); values.AddComponent("GameValues"); values.transform.parent = transform; numButtons=0; GameObject next = new GameObject("BuildConfirmMenu"); next.AddComponent("BuildConfirmMenu"); next.transform.parent = transform; BuildConfirmMenu nextBCM = next.GetComponent<BuildConfirmMenu>(); nextBCM.click = click; nextBCM.squareStyle = squareStyle; Rect weaponButtonRect = new Rect(100, 100, buttonSize.x, buttonSize.y); for(int i=0; i< Faction.NUM_WEAPONS; i++) { weaponButtonRect = new Rect(795, (435) + ( ( i * ((150/(Faction.NUM_WEAPONS))+5)) ), 160, 150/(Faction.NUM_WEAPONS)); //weaponButtonRect = FindPos(numButtons, weaponButtonRect); GameObject item = MakeButton("", weaponButtonRect); item.AddComponent("WeaponCostLabelUpdate"); WeaponCostLabelUpdate itemWCLU = item.GetComponent<WeaponCostLabelUpdate>(); itemWCLU.weaponName = ""; item.AddComponent("BuildConfirmMenu"); item.transform.parent = transform; m = item.GetComponent<MenuItem>(); m.action = itemWCLU; m.tooltipSkin = squareStyle; m.SetTooltipLabel(false); m.tooltipHeight = 60; m.tooltipWidth = 100; m.tooltipLeftRel = -105; m.tooltipTopRel = 0; //m.guiSkin = squareStyle; itemWCLU.fromMenu = this.gameObject; itemWCLU.toMenu = next; //item.GetComponent<BuildConfirmMenu>().click = click; //item.GetComponent<BuildConfirmMenu>().squareStyle = squareStyle; menuItems.Add(m); weaponButtons[i] = m; //weaponButtonRect.xMin += buttonSize.x + 15; //if(i%2 == 0 && i > 0) { //weaponButtonRect.yMin += buttonSize.y + 5; //weaponButtonRect.xMin -= 3*(buttonSize.x + 15); //} numButtons++; } Rect backButtonRect = new Rect(730,435,60,160); //backButtonRect = FindPos(numButtons, backButtonRect); GameObject back = MakeButton("Back",backButtonRect); back.AddComponent("SwitchMenu"); SwitchMenu backSM = back.GetComponent<SwitchMenu>(); back.transform.parent = transform; m1 = back.GetComponent<MenuItem>(); m1.action = backSM; /*m1.tooltipSkin = squareStyle; m1.SetTooltipLabel(false); m1.tooltip = "Go back to the previous screen."; m1.tooltipHeight = 75; m1.tooltipWidth = 100; m1.tooltipLeftRel = -105; m1.tooltipTopRel = 0;*/ backSM.fromMenu = this.gameObject; backSM.toMenu = this.transform.parent.gameObject; m1.action.click = click; //m1.guiSkin = squareStyle; menuItems.Add(m1); numButtons++; hasLoaded = true; } base.Update(); }