public Hero(ObjectType mObjectType, ContentManager content, SpriteState defaultState, Vector2 SpritePosition) : base(mObjectType, content, defaultState, SpritePosition, Hostility.FRIENDLY) { mSpriteScale = 0.8f; this.mSprite.SpriteScale = mSpriteScale; this.hostility = Hostility.FRIENDLY; SetUnitAnimation(); mTarget = SpritePosition; mBehaviorHero = new BehaviorHero(1.0f, mTarget); mObjectID = mGlobalID; mGlobalID++; mheroAttribute = new HeroAttribute(this, content); SetAttributes(); int mAttackLevel = (int)HeroAttribute.AttackUpgradeLevel; int mDefenseLevel = (int)HeroAttribute.DefenseUpgradeLevel; for (int i = 0; i < mAttackLevel; i++) { mheroAttribute.UpgradeAttack(); } for (int i = 0; i < mDefenseLevel; i++) { mheroAttribute.UpgradeDefense(); } }
private SpriteState SetHighlightedImage(SpriteState spr_st, Sprite sprite) { SpriteState spr = spr_st; spr.highlightedSprite = sprite; return(spr); }
public void SetSlider(Sprite normal, Sprite highlight, Sprite pressed, Sprite disabled, Sprite background) { foreach (var image in GetComponentsInChildren <Image> ()) { if (image.gameObject.name == "Background") { image.sprite = background; image.type = Image.Type.Sliced; } } Slider slider = GetComponent <Slider>(); if (slider != null) { slider.image.sprite = normal; slider.image.type = Image.Type.Sliced; slider.transition = Selectable.Transition.SpriteSwap; SpriteState spriteState = slider.spriteState; spriteState.highlightedSprite = highlight; spriteState.pressedSprite = pressed; spriteState.disabledSprite = disabled; slider.spriteState = spriteState; } SetImage(background, Image.Type.Sliced); }
public void Restart() { SpriteState state = new SpriteState(); if (GameModel.State != GameState.Moving) { foreach (var cellView in _cellViews) { cellView.Kill(); } _cellViews.Clear(); state.highlightedSprite = _restartButtonNormalHoverStateSprite; _restartButton.GetComponent <Button>().spriteState = state; _restartButton.GetComponent <Button>().image.sprite = _restartButtonNormalStateSprite; EventSystem.OnRestartInvoke(); } else if (GameModel.State == GameState.Win) { WinPanel.Disable(); state.highlightedSprite = _restartButtonNormalHoverStateSprite; _restartButton.GetComponent <Button>().spriteState = state; _restartButton.GetComponent <Button>().image.sprite = _restartButtonNormalStateSprite; } else { Debug.Log("Restart DENIED!!!"); } }
static SpriteState?ParseSpriteState(ConfigNode node) { if (node == null) { return(null); } SpriteState sprites = new SpriteState(); { if (SpriteLoader.GetSprite(node.GetValue("highlightedSprite")) is Sprite s) { sprites.highlightedSprite = s; } } { if (SpriteLoader.GetSprite(node.GetValue("pressedSprite")) is Sprite s) { sprites.pressedSprite = s; } } { if (SpriteLoader.GetSprite(node.GetValue("selectedSprite")) is Sprite s) { sprites.selectedSprite = s; } } { if (SpriteLoader.GetSprite(node.GetValue("disabledSprite")) is Sprite s) { sprites.disabledSprite = s; } } return(sprites); }
/// <summary> /// Set background image and cancel button for the appropriate side /// </summary> /// <param name="side"></param> private void ChangeSides(GlobalSide side) { Debug.Assert(side != null, "Invalid side (Null)"); switch (side.level) { case 1: backgroundPanel.sprite = GameManager.i.sideScript.info_background_Authority; buttonClose.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Authority; //set sprite transitions SpriteState spriteStateAuthority = new SpriteState(); spriteStateAuthority.highlightedSprite = GameManager.i.sideScript.button_highlight_Authority; spriteStateAuthority.pressedSprite = GameManager.i.sideScript.button_Click; buttonClose.spriteState = spriteStateAuthority; break; case 2: backgroundPanel.sprite = GameManager.i.sideScript.info_background_Resistance; buttonClose.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Resistance; //set sprite transitions SpriteState spriteStateRebel = new SpriteState(); spriteStateRebel.highlightedSprite = GameManager.i.sideScript.button_highlight_Resistance; spriteStateRebel.pressedSprite = GameManager.i.sideScript.button_Click; buttonClose.spriteState = spriteStateRebel; break; } }
protected override void GUI() { base.GUI(); Selectable.Transition transition = Selectable.Transition.SpriteSwap; Sprite backgroundSprite = Data.BackgroundSprite; Sprite handleSprite = Data.DefaultHandleSprite; SpriteState spriteState = Data.DefaultHandleSpriteState; ColorBlock colors = new ColorBlock(); colors.colorMultiplier = 1; colors.fadeDuration = 0.1f; switch (Type) { case ScrollbarType.Default: transition = Selectable.Transition.ColorTint; colors.normalColor = Data.NormalColor; colors.highlightedColor = Data.HighlightedColor; colors.pressedColor = Data.PressedColor; colors.disabledColor = Data.DisableColor; break; } // Set Scrollbar scrollbar.transition = transition; scrollbar.colors = colors; scrollbar.spriteState = spriteState; backgroundImage.sprite = backgroundSprite; handleImage.sprite = handleSprite; }
/// <summary> /// 改变按钮高亮的图片 /// </summary> /// <param name="highlighted"></param> /// <returns></returns> public SpriteState ChangeButtonSprite(Sprite highlighted) { SpriteState ss = new SpriteState(); ss.highlightedSprite = highlighted; return(ss); }
/// <summary> /// 添加条目 /// </summary> /// <returns></returns> public CommonListItem AddItem() { CommonListItem newItem = new CommonListItem(); newItem.itemObject = GameCloneUtils.CloneNewObjectWithParent(ItemPrefab, rectTransform.transform); newItem.itemRectTransform = newItem.itemObject.GetComponent <RectTransform>(); newItem.backgroundImage = newItem.itemObject.AddComponent <Image>(); newItem.backgroundImage.type = Image.Type.Sliced; newItem.backgroundImageButton = newItem.itemObject.AddComponent <Button>(); newItem.backgroundImageButton.transition = Selectable.Transition.SpriteSwap; newItem.backgroundImage.sprite = itemBackgroundNormal; newItem.visible = true; newItem.selected = false; SpriteState spriteState = new SpriteState(); spriteState.highlightedSprite = itemBackgroundHover; spriteState.selectedSprite = itemBackgroundSelected; spriteState.pressedSprite = itemBackgroundPressed; spriteState.disabledSprite = itemBackgroundPressed; newItem.backgroundImageButton.spriteState = spriteState; EventTriggerListener.Get(newItem.itemObject).onClick = (g) => OnItemClicked(newItem); List.Add(newItem); needRelayout = 10; return(newItem); }
public void SetAttackButtonSprite() { SpriteState sps = new SpriteState(); switch (EnvironmentController.instance.set.setType) { case SetType.Forest: attackbutton.image.sprite = attackButtonsForest[0]; attackCooldownButton.sprite = attackButtonsForest[0]; sps.pressedSprite = attackButtonsForest[1]; break; case SetType.Desert: attackbutton.image.sprite = attackButtonsDesert[0]; attackCooldownButton.sprite = attackButtonsDesert[0]; sps.pressedSprite = attackButtonsDesert[1]; break; case SetType.Ice: attackbutton.image.sprite = attackButtonsIce[0]; attackCooldownButton.sprite = attackButtonsIce[0]; sps.pressedSprite = attackButtonsIce[1]; break; default: break; } attackbutton.spriteState = sps; }
void MoveUnicorn() { if (movingAllowed) { bool TargetReached = false; Vector2 currentPosition = transform.position; var distanceLeft = targetCoordinate - currentPosition; const float minimalPositionDiff = 0.1f; //Ej siffror i koden, samla under ett namn. Lättare att bara ändra på ett ställe. Mindre diff. if (distanceLeft.magnitude < minimalPositionDiff) { TargetReached = true; state = SpriteState.Idle; } if (!TargetReached) { state = SpriteState.Moving; float velocity; if (distanceLeft.magnitude < positionNear) { velocity = velocityNear; } else { velocity = velocityFar; } MovementHandler(velocity); } } }
} // END addGameObjects void addToInventory() { bool slotFound = false; buttons = base.invBox.GetComponentsInChildren <Button>(); foreach (Button thisOne in buttons) // Loop through each button inside the inventory "box" { if (thisOne.GetComponent <slot>().slotEmpty&& !slotFound) { playPickupSound(thisObject.GetComponent <proxObj>().soundType); string tempNameString = thisObject.GetComponent <proxObj>().itemName; if (tempNameString != "" && tempNameString[0] == '~') { tempNameString = tempNameString.Substring(1); } thisOne.name = tempNameString; thisOne.GetComponent <slot>().itemName = thisObject.GetComponent <proxObj>().itemName; if (thisObject.GetComponent <proxObj>().DescriptionInventory == "" || thisObject.GetComponent <proxObj>().DescriptionInventory == null) { thisOne.GetComponent <slot>().DescriptionGame = thisObject.GetComponent <proxObj>().DescriptionGame; } else { thisOne.GetComponent <slot>().DescriptionGame = thisObject.GetComponent <proxObj>().DescriptionInventory; } thisOne.GetComponent <slot>().DescriptionInventory = thisObject.GetComponent <proxObj>().DescriptionInventory; thisOne.GetComponent <slot>().useWith = thisObject.GetComponent <proxObj>().useWith; thisOne.GetComponent <slot>().soundType = thisObject.GetComponent <proxObj>().soundType; thisOne.GetComponent <slot>().slotEmpty = false; thisOne.GetComponent <slot>().spriteNorm = thisObject.GetComponent <proxObj>().spriteNorm; thisOne.GetComponent <slot>().spriteHigh = thisObject.GetComponent <proxObj>().spriteHigh; thisOne.GetComponent <slot>().spriteNorm2 = thisObject.GetComponent <proxObj>().spriteNorm2; thisOne.GetComponent <slot>().spriteHigh2 = thisObject.GetComponent <proxObj>().spriteHigh2; thisOne.GetComponent <slot>().overlayNorm2 = thisObject.GetComponent <proxObj>().overlayNorm2; thisOne.GetComponent <slot>().overlayHigh2 = thisObject.GetComponent <proxObj>().overlayHigh2; thisOne.GetComponent <Image>().sprite = thisObject.GetComponent <proxObj>().spriteNorm; SpriteState st = new SpriteState(); st.highlightedSprite = thisObject.GetComponent <proxObj>().spriteHigh; st.pressedSprite = thisObject.GetComponent <proxObj>().spriteNorm; thisOne.spriteState = st; slotFound = true; inventoryCheck.Add(thisObject.GetComponent <proxObj>().itemName); // once slot has been set remove the selected object from game Destroy(thisObject); break; // break statement appears to not work at all, it sets every button anyhoo } } if (!slotFound) { // all slots are full, no more room in inventory base.displayMessage("Inventory full, please clear something out before trying to add something new."); } } // END addToInventory
private void UpdateToggleButton(bool isOn) { if (toggleState == isOn) { return; } toggleState = isOn; if (ExperimentSelectable == null) { return; } if (ToggleIcons.Length < 6) { return; } ExperimentSelectable.image.sprite = isOn ? ToggleIcons[3] : ToggleIcons[0]; ExperimentSelectable.image.type = Image.Type.Simple; ExperimentSelectable.transition = Selectable.Transition.SpriteSwap; SpriteState state = ExperimentSelectable.spriteState; state.highlightedSprite = isOn ? ToggleIcons[4] : ToggleIcons[1]; state.pressedSprite = isOn ? ToggleIcons[5] : ToggleIcons[2]; state.disabledSprite = null; ExperimentSelectable.spriteState = state; }
/// <summary> /// Updates the alert /// </summary> /// <param name="gameTime"></param> public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { base.Update(gameTime); if (!this.Enabled) { return; } _alertTime += (Single)gameTime.ElapsedGameTime.TotalSeconds; // Update opacity this.Color = Color.Lerp(this.Color, this.CurrentState == SpriteState.TransitionOff ? Color.Transparent : Color.White, (Single)gameTime.ElapsedGameTime.TotalSeconds * 5); // Kill transition if (_alertTime > MaxAlertTime) { this.CurrentState = SpriteState.TransitionOff; if (this.Color.A < 5) { this.CurrentState = SpriteState.Hidden; this.Enabled = false; this.Visible = false; this.OnFinished.Invoke(this, EventArgs.Empty); } } }
public void ChangeColorSelectorClass(int index) { SpriteState tmpSpriteState = new SpriteState(); for (int i = 0; i < currentClass.Length; i++) { currentClass[i].image.sprite = classesButton[index, 0, i]; tmpSpriteState.highlightedSprite = classesButton[index, 1, i]; currentClass[i].spriteState = tmpSpriteState; } for (int i = 0; i < currentFaction.Length; i++) { currentFaction[i].image.sprite = transparency; } currentClass[currentclass].image.sprite = classesButton[index, 1, currentclass]; currentFaction[index].image.sprite = highlightedFaction[index]; currentFond.sprite = fond[index]; currentFlag.sprite = flag[index]; for (int i = 0; i < allButtons.Length; i++) { allButtons[i].image.sprite = sm.factionButtonMenu[index, 1]; tmpSpriteState.highlightedSprite = sm.factionButtonMenu[index, 0]; allButtons[i].spriteState = tmpSpriteState; } }
private void Generate(int count) { var button = Instantiate(prefabDialButton); button.name = "button_" + (count + 1); button.transform.SetParent(transform); // Картинка //button.GetComponent<Image>().sprite = graphicTarget[count].sprite; button.GetComponent <Image>().sprite = graphicTargetAlt[count]; var spr = new SpriteState(); //spr.pressedSprite = graphicPressed[count].sprite; //spr.highlightedSprite = graphicPressed[count].sprite; spr.pressedSprite = graphicTargetAlt[count]; spr.highlightedSprite = graphicPressedAlt[count]; button.GetComponent <Button>().spriteState = spr; // положение на экране button.GetComponent <RectTransform>().localScale = new Vector3(1f, 1f, 1f); try { button.GetComponent <RectTransform>().Rotate(rotationButtons[count]); button.transform.localPosition = coordButtons[count]; button.GetComponent <RectTransform>().sizeDelta = sizeButtons[count]; } catch { print("Положение на экране не задано"); } }
public Friendly(ObjectType mObjectType, ContentManager content, SpriteState defaultState, Vector2 SpritePosition, Vector2 mDefaultTarget, int mAttackLevel, int mDefenseLevel) : base(mObjectType, content, defaultState, SpritePosition, Hostility.FRIENDLY) { this.DefaultTarget = mDefaultTarget; this.mCurrentTarget = mDefaultTarget; this.hostility = Hostility.FRIENDLY; mBehaviorFriendly = new BehaviorFriendly(1.0f); mFieldOfViewSize = 300; mObjectID = mGlobalID; mGlobalID++; SetUnitAnimation(); mFriendlyAttribute = new FriendlyAttribute(this, content); if (GameObject.FromSaveGameState == FromSaveGame.NEWGAME) { SetAttributes(); } this.FriendlyAggroMode = FriendlyAggroMode.MOVING; for (int i = 0; i < mAttackLevel; i++) { mFriendlyAttribute.UpgradeAttack(); } for (int i = 0; i < mDefenseLevel; i++) { mFriendlyAttribute.UpgradeDefense(); } }
public static SpriteState StringToSpriteState(string value, string spriteFolderPath) { var array = GroupToArray(value); if (array == null) { return(default(SpriteState)); } SpriteState spriteState = new SpriteState(); for (int i = 0; i < array.Length; i++) { var sprite = StringToObject <Sprite>(array[i], spriteFolderPath); if (sprite == null) { continue; } if (i == 0) { spriteState.highlightedSprite = sprite; } else if (i == 1) { spriteState.pressedSprite = sprite; } else if (i == 2) { spriteState.disabledSprite = sprite; } } return(spriteState); }
} // END playPickupSound void clearEmptySlots() { buttons = base.invBox.GetComponentsInChildren <Button>(); foreach (Button thisOne in buttons) // Loop through each button inside the inventory "box" { if (thisOne.GetComponent <slot>().slotEmpty) { thisOne.name = "slot"; // change slot variables to emptySlot thisOne.GetComponent <slot>().itemName = null; thisOne.GetComponent <slot>().DescriptionGame = null; thisOne.GetComponent <slot>().useWith = null; thisOne.GetComponent <slot>().slotEmpty = true; thisOne.GetComponent <slot>().spriteNorm = emptySlot.GetComponent <slot>().spriteNorm; thisOne.GetComponent <slot>().spriteHigh = emptySlot.GetComponent <slot>().spriteHigh; thisOne.GetComponent <slot>().spriteNorm2 = emptySlot.GetComponent <slot>().spriteNorm2; thisOne.GetComponent <slot>().spriteHigh2 = emptySlot.GetComponent <slot>().spriteHigh2; thisOne.GetComponent <slot>().overlayNorm2 = emptySlot.GetComponent <slot>().overlayNorm2; thisOne.GetComponent <slot>().overlayHigh2 = emptySlot.GetComponent <slot>().overlayHigh2; thisOne.GetComponent <Image>().sprite = emptySlot.GetComponent <slot>().spriteNorm; SpriteState st = new SpriteState(); st.highlightedSprite = emptySlot.GetComponent <slot>().spriteNorm; st.pressedSprite = emptySlot.GetComponent <slot>().spriteNorm; thisOne.spriteState = st; break; } } } // END clearEmptySlots
//生成UI public override void ModifyToUi(RectTransform root, RectTransform t, string[] sourceDirs) { ModifySize(root, t, normal); Button button = t.GetComponent <Button>(); if (button == null) { button = t.gameObject.AddComponent <Button>(); var image = t.gameObject.AddComponent <Image>(); button.targetGraphic = image; } Sprite normalSprite = GetSpriteFromDirectories(normalPiece.name, sourceDirs); Sprite pressedSprite = null; if (pressed != null) { pressedSprite = GetSpriteFromDirectories(pressedPiece.name, sourceDirs); } Sprite disabledSprite = null; if (disabled != null) { disabledSprite = GetSpriteFromDirectories(disabledPiece.name, sourceDirs); } SpriteState state = new SpriteState(); state.pressedSprite = pressedSprite; state.disabledSprite = disabledSprite; button.image.sprite = normalSprite; button.spriteState = state; }
public void AddAction(Sprite active, Sprite idle, UnityAction call) { if (onToggle == null) { SpriteState newSprites = new SpriteState(); newSprites.disabledSprite = idle; newSprites.highlightedSprite = idle; newSprites.pressedSprite = active; spriteState = newSprites; this.GetComponent <Image>().sprite = idle; highlightedSprite = idle; /*if (call != null) * { * interactable = true; * onClick.AddListener(call); * }*/ onToggle = call; } else { onUntoggle = call; } if (onToggle == null) { interactable = false; } }
// Update is called once per frame void Update() { if (myCurrentScene != "start") { SpriteState spriteState1 = buttonStart.spriteState; spriteState1.highlightedSprite = ImgContinueSelect; buttonStart.spriteState = spriteState1; } if (Input.GetButtonDown("Vertical")) { menusound(); } if (Input.GetMouseButtonDown(0)) { menusound(); } if (Input.GetMouseButtonDown(1)) { menusound(); } if (Input.GetMouseButtonDown(2)) { menusound(); } }
void Start() { ui_layout(); ss = new SpriteState(); ss2 = new SpriteState(); Debug.Log("InfoPanelController 启动"); }
public static void AddButtonEffect(GameObject go, string pressedSprite = null, string disableSprite = null) { Button btn = go.GetComponent <Button>(); if (btn == null) { btn = go.AddComponent <Button>(); } btn.enabled = true; Sprite pres = null, diss = null; if (pressedSprite != null) { pres = ResourceManager.LoadSprite(pressedSprite); } if (disableSprite != null) { diss = ResourceManager.LoadSprite(disableSprite); } if (pres != null || diss != null) { btn.transition = Selectable.Transition.SpriteSwap; SpriteState ss = new SpriteState(); ss.pressedSprite = pres; ss.disabledSprite = diss; btn.spriteState = ss; } else { btn.transition = Selectable.Transition.ColorTint; } }
public void GameOver() { //returnButton.GetComponentInChildren<Text>().text = "Play Again?"; howToPlayButton.gameObject.SetActive(false); howToPlayButton.interactable = false; pauseMenuSelection.transform.position = returnButton.transform.position; //Change sprite returnButton.image.sprite = playAgainSprite; //Sprite state for changing highlighted sprite SpriteState playAgainSpriteState = new SpriteState(); //Get button's state playAgainSpriteState = returnButton.spriteState; //Change sprites playAgainSpriteState.highlightedSprite = playAgainSpritePressed; playAgainSpriteState.pressedSprite = playAgainSprite; //Set state returnButton.spriteState = playAgainSpriteState; ShowPauseMenu(); returnButton.onClick.AddListener(gameController.reloadScene); }
//public AudioSource UINavigate; //public AudioSource UISelect; void Awake() { //inputManager = InpManOBJ.GetComponent<InputManagerScript>(); //if (inputManager == null) //{ // inputManager = FindObjectOfType<InputManagerScript>(); //} menuBtns = new List <Button>(menuList.childCount); for (int i = 0; i < (menuList.childCount); i++) { menuBtns.Add(menuList.GetChild(i).GetComponent <Button>()); } currentBtn = menuBtns[0]; ////currentBtn.Select(); //ColorBlock cb = currentBtn.colors; //cb.normalColor = cb.highlightedColor; //currentBtn.colors = cb; ////currentBtn.colors.highlightedColor = SelectedColor; SpriteState cb = currentBtn.spriteState; currentBtn.image.sprite = cb.highlightedSprite; //currentBtn.colors = cb; sfxNavigate = GameObject.FindGameObjectWithTag("sfxNavigate").GetComponent <AudioSource>(); sfxSelect = GameObject.FindGameObjectWithTag("sfxSelect").GetComponent <AudioSource>(); // sfxNext = GameObject.FindGameObjectWithTag("sfxNext").GetComponent<AudioSource>(); //sfxBack = GameObject.FindGameObjectWithTag("sfxBack").GetComponent<AudioSource>(); //Debug.Log(currentBtn.name + " , " + currentBtn.colors.highlightedColor); }
public Sprite GetCurrentSprite(SpriteState currentState, bool front, float hurtTime) { if (hurtTime > 0) { return front ? HurtF : HurtB; } else { switch (currentState) { case SpriteState.Idle: return front ? IdleF[Mathf.FloorToInt((Time.timeSinceLevelLoad * IDLEFRAMESPERSECOND) % IdleF.Count)] : IdleB[Mathf.FloorToInt((Time.timeSinceLevelLoad * IDLEFRAMESPERSECOND) % IdleB.Count)]; case SpriteState.Walk: return front ? WalkF[Mathf.FloorToInt((Time.timeSinceLevelLoad * WALKFRAMESPERSECOND) % WalkF.Count)] : WalkB[Mathf.FloorToInt((Time.timeSinceLevelLoad * WALKFRAMESPERSECOND) % WalkB.Count)]; case SpriteState.PreStrike: return front ? PreStrikeF : PreStrikeB; case SpriteState.Strike: return front ? StrikeF : StrikeB; case SpriteState.Hurt: return front ? HurtF : HurtB; default: Debug.LogError("Not implemented in GetCurrentSprite: " + currentState); return null; } } }
public Enemy(ObjectType mObjectType, ContentManager content, SpriteState defaultState, Castle castle, Vector2 SpritePosition) : base(mObjectType, content, defaultState, SpritePosition, Hostility.ENEMY) { isInPlay = true; this.hostility = Hostility.ENEMY; mFieldOfViewSize = 200; SetUnitAnimation(); random = new Random(); y = random.Next(25, 700); mDefaultTarget = new Rectangle(1400, y, 200, 775); mCurrentTarget = new Vector2(mDefaultTarget.X, mDefaultTarget.Y); mBehaviorEnemy = new BehaviorEnemy(1.0f); mObjectID = mGlobalID; mGlobalID++; enemyAttribute = new EnemyAttribute(this, content, castle); SetAttributes(); this.AttackState = AttackState.READY; enemyAttribute.UpgradeAttack(); enemyAttribute.UpgradeDefense(); }
public void SetAllocate(Sefira currentSefira) { if (currentSefira == null) { ui.Allocate.image.sprite = allocate_normal; SpriteState sets = ui.Allocate.spriteState; sets.highlightedSprite = allocate_overlay; sets.disabledSprite = allocate_normal; sets.pressedSprite = allocate_overlay; ui.Allocate.spriteState = sets; return; } if (currentSefira.name == SefiraName.Malkut) { ui.Allocate.image.sprite = allocate_malkut; SpriteState sets = ui.Allocate.spriteState; sets.highlightedSprite = allocate_malkut; sets.disabledSprite = allocate_malkut; sets.pressedSprite = allocate_malkut; ui.Allocate.spriteState = sets; } else if (currentSefira.name == SefiraName.Yesod) { ui.Allocate.image.sprite = allocate_yesod; SpriteState sets = ui.Allocate.spriteState; sets.highlightedSprite = allocate_yesod; sets.disabledSprite = allocate_yesod; sets.pressedSprite = allocate_yesod; ui.Allocate.spriteState = sets; } }
/// <summary> /// Initializes the <see cref="Common.UI.Popups.Internal.PopupMenuCommon"/> class. /// </summary> static WindowCommon() { minimizeButtonSpriteState = new SpriteState(); maximizeButtonSpriteState = new SpriteState(); normalizeButtonSpriteState = new SpriteState(); closeButtonSpriteState = new SpriteState(); toolCloseButtonSpriteState = new SpriteState(); minimizeButtonSpriteState.disabledSprite = Assets.Windows.Common.Textures.minimizeButtonDisabled; minimizeButtonSpriteState.highlightedSprite = Assets.Windows.Common.Textures.minimizeButtonHighlighted; minimizeButtonSpriteState.pressedSprite = Assets.Windows.Common.Textures.minimizeButtonPressed; maximizeButtonSpriteState.disabledSprite = Assets.Windows.Common.Textures.maximizeButtonDisabled; maximizeButtonSpriteState.highlightedSprite = Assets.Windows.Common.Textures.maximizeButtonHighlighted; maximizeButtonSpriteState.pressedSprite = Assets.Windows.Common.Textures.maximizeButtonPressed; normalizeButtonSpriteState.disabledSprite = Assets.Windows.Common.Textures.normalizeButtonDisabled; normalizeButtonSpriteState.highlightedSprite = Assets.Windows.Common.Textures.normalizeButtonHighlighted; normalizeButtonSpriteState.pressedSprite = Assets.Windows.Common.Textures.normalizeButtonPressed; closeButtonSpriteState.disabledSprite = Assets.Windows.Common.Textures.closeButtonDisabled; closeButtonSpriteState.highlightedSprite = Assets.Windows.Common.Textures.closeButtonHighlighted; closeButtonSpriteState.pressedSprite = Assets.Windows.Common.Textures.closeButtonPressed; toolCloseButtonSpriteState.disabledSprite = Assets.Windows.Common.Textures.toolCloseButtonDisabled; toolCloseButtonSpriteState.highlightedSprite = Assets.Windows.Common.Textures.toolCloseButtonHighlighted; toolCloseButtonSpriteState.pressedSprite = Assets.Windows.Common.Textures.toolCloseButtonPressed; }
//生成Preview public override void ModifyToPreview(RectTransform root, RectTransform t) { ModifySize(root, t, this.normal); Rect btnRect = new Rect(0, 0, this.normal.Width, this.normal.Height); Image image = t.gameObject.AddComponent <Image>(); Button button = t.gameObject.AddComponent <Button>(); button.targetGraphic = image; Sprite normal = Sprite.Create(normalPiece.tex, btnRect, Vector2.zero); image.sprite = normal; if (pressed != null || disabled != null) { button.transition = Selectable.Transition.SpriteSwap; Sprite pressed = null; Sprite disabled = null; if (this.pressed != null) { pressed = Sprite.Create(pressedPiece.tex, btnRect, Vector2.zero); } if (this.disabled != null) { disabled = Sprite.Create(disabledPiece.tex, btnRect, Vector2.zero); } SpriteState state = new SpriteState(); state.pressedSprite = pressed; state.disabledSprite = disabled; button.spriteState = state; } }
public void ApplyChanges() { buttons = GetComponentsInChildren(typeof(Button), true); foreach (Button button in buttons) { button.image.color = new Color32(255, 255, 255, 255); //button.image.rectTransform.sizeDelta = new Vector2(400, 100); button.image.sprite = buttonTexture; Text tmptext = button.GetComponentInChildren <Text>(); tmptext.color = new Color32(94, 47, 16, 255); tmptext.fontStyle = FontStyle.Normal; tmptext.fontSize = 60; button.transition = Selectable.Transition.SpriteSwap; SpriteState st = new SpriteState(); st.highlightedSprite = buttonOverTexture; st.pressedSprite = buttonOverTexture; st.disabledSprite = null; button.spriteState = st; //ColorBlock cb = button.colors; //cb.normalColor = new Color32(255, 255, 255, 255); //cb.highlightedColor = new Color32(255, 255, 255, 200); //cb.disabledColor = new Color32(255, 255, 255, 120); //button.colors = cb; } }
public void Initialize(Texture2D textureIdle, Texture2D textureWalk, Vector2 position, int frameWidth, int frameHeight, int frameCount, float frametime, Color color, float scale, bool looping) { // Keep a local copy of the values passed in this.color = color; this.FrameWidth = frameWidth; this.FrameHeight = frameHeight; this.frameCount = frameCount; this.frameTime = frametime; this.scale = scale; Looping = looping; Position = position; spriteStripIdle = textureIdle; //spriteStripJump = textureJump; //spriteStripClimbUp = textureClimbUp; //spriteStripClimbDown = textureClimbDown; spriteStripWalk = textureWalk; spriteState = SpriteState.None; currentFrame = 0; // Set the Animation to active by default Active = true; Animating = true; Alive = true; }
public static void ChangePlayerDeploy(GamePhase gP) { SpriteState tempState = new SpriteState(); instance.deployButtons[0].image.sprite = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "Button"); tempState.highlightedSprite = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "Button"); tempState.pressedSprite = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "ButtonPressed"); tempState.disabledSprite = Resources.Load <Sprite>("Pictures/DeployInf" + (PlayerMaster.CurrentTurn) + "ButtonDisabled"); instance.deployButtons[0].spriteState = tempState; instance.deployButtons[1].image.sprite = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "Button"); tempState.highlightedSprite = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "Button"); tempState.pressedSprite = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "ButtonPressed"); tempState.disabledSprite = Resources.Load <Sprite>("Pictures/DeployCav" + (PlayerMaster.CurrentTurn) + "ButtonDisabled"); instance.deployButtons[1].spriteState = tempState; instance.deployButtons[2].image.sprite = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "Button"); tempState.highlightedSprite = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "Button"); tempState.pressedSprite = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "ButtonPressed"); tempState.disabledSprite = Resources.Load <Sprite>("Pictures/DeployCannon" + (PlayerMaster.CurrentTurn) + "ButtonDisabled"); instance.deployButtons[2].spriteState = tempState; if (gP != GamePhase.Deploy) { SetPlayerUnitInfo(); } }
private void UnlockLevels(int currentLevelIndex) { string LetterToChangeToSmall; if (PlayerPrefs.HasKey("SmallLevelToActive")) { string[] smallLevelToActive = PlayerPrefs.GetString("SmallLevelToActive").Split("_".ToCharArray()); LetterToChangeToSmall = smallLevelToActive[0]; foreach (Button levelBtn in alphabetsLevels) { if (levelBtn.name == LetterToChangeToSmall) { levelBtn.image.sprite = Resources.Load <Sprite>("SmallLettersButtonIcons/" + LetterToChangeToSmall.ToLower()); SpriteState spriteState = new SpriteState(); spriteState.pressedSprite = Resources.Load <Sprite>("SmallLettersButtonIcons/clicked/" + LetterToChangeToSmall.ToLower()); levelBtn.spriteState = spriteState; } } } for (int i = 0; i < alphabetsLevels.Length; i++) { if ((i + 1) <= currentLevelIndex) { alphabetsLevels[i].interactable = true; } else { alphabetsLevels[i].interactable = false; } } }
public Sprite(ISpriteData data) { this.SpriteData = data; // Sprite is initialized with current state is stop state = SpriteState.STOPPED; // Init with first frame nextFrame = DEFAULT_FRAME; this.currentFrame = this.SpriteData.Metadata.Frames[nextFrame]; // Init with smallest time lastTime = new TimeSpan(-100000000); }
public ItemDrop(int value, ObjectType mObjectType, ContentManager content, SpriteState defaultState, Vector2 SpritePosition, Hostility hostility) : base(mObjectType, content, defaultState, SpritePosition, hostility) { this.mObjectType = mObjectType; mIsTagged = false; mTimeToLive = 10000; mTimer = 0; mSpawnLocation = SpritePosition; this.mValue = value; mSprite = new Sprite(content); SetItemDropAnimation(); mSprite.LoadContent(); mSprite.WorldPosition = mSpawnLocation; }
public Structure(ObjectType mStructureType, ContentManager content, SpriteState defaultState, Vector2 SpritePosition, ObjectColor mStructureColor, Vector2 ButtonPosition) : base(mStructureType, content, defaultState, SpritePosition, Hostility.STRUCTURE) { this.mStructureType = mStructureType; this.mStructureColor = mStructureColor; this.content = content; this.defaultState = defaultState; this.mSpritePosition = SpritePosition; this.mButtonPosition = ButtonPosition; mStructureAttribute = new StructureAttribute(content, this); SetAttributes(); SetUnitAnimation(); }
/// <summary> /// Seta o estado corrente /// </summary> /// <param name="spriteState">Indica o estado selecionado</param> public void SetState(SpriteState spriteState) { if (spriteState != this.lastSpriteState) { bool result = this.animationElements.Keys.Contains(spriteState); if (result == true) { this.spriteState = spriteState; this.Image = animationElements[this.spriteState].Image; this.index = 0; this.lastSpriteState = spriteState; } } }
/// <summary> /// CONSTRUTOR /// </summary> /// <param name="spriteState">Estado do sprite (tipo)</param> /// <param name="image">Imagem</param> /// <param name="rows">Quantidade de linhas</param> /// <param name="columns">Quantidade de colunas</param> /// <param name="framesPerSecond">frames por segundo</param> public AnimationElement(SpriteState spriteState, Texture2D image, int rows, int columns, int framesPerSecond) { // Inicializa as variáveis this.spriteState = spriteState; this.image = image; this.rows = rows; this.columns = columns; this.framesPerSecond = framesPerSecond; this.rectangles = new List<Rectangle>(); this.frameWidth = this.image.Width / columns; this.frameHeight = this.image.Height / rows; // Monta os frames this.BuildFrames(); }
/// <summary> /// Initializes the <see cref="Common.UI.Popups.Internal.PopupMenuCommon"/> class. /// </summary> static PopupMenuCommon() { buttonSpriteState = new SpriteState(); buttonDisabledSpriteState = new SpriteState(); buttonSpriteState.disabledSprite = Assets.Popups.Textures.button; buttonSpriteState.highlightedSprite = Assets.Popups.Textures.buttonHighlighted; buttonSpriteState.pressedSprite = Assets.Popups.Textures.buttonHighlighted; buttonDisabledSpriteState.disabledSprite = Assets.Popups.Textures.button; buttonDisabledSpriteState.highlightedSprite = Assets.Popups.Textures.buttonDisabled; buttonDisabledSpriteState.pressedSprite = Assets.Popups.Textures.buttonDisabled; defaultNavigation = Navigation.defaultNavigation; noneNavigation = new Navigation(); noneNavigation.mode = Navigation.Mode.None; }
public Projectile(ObjectType mObjectType, SpriteState defaultState, Vector2 SpritePosition, Hostility hostility, GameObject mProjectileTargetObject, GameObject mProjectileCaster, float mProjectileDamage, ContentManager content) : base(mObjectType, content, defaultState, SpritePosition, hostility) { mObjectID = mGlobalID; mGlobalID++; mSpeed = 5.0f; randomNumberGenerator = new Random(); this.mProjectileDamage = mProjectileDamage; this.mProjectileCaster = mProjectileCaster; this.mProjectileTargetObject = mProjectileTargetObject; this.mCurrentTarget = mProjectileTargetObject.Sprite.WorldPosition; this.mTrackingNumber = this.mProjectileTargetObject.mObjectID; mHasLanded = false; }
public Sprite(Texture2D spriteSheet, int spriteWidth, int spriteHeight, int numFrames, int numStates, TimeSpan animationTime, int moveSpeed) { _spriteSheet = spriteSheet; _hitRect = new Rectangle(0, 0, spriteWidth, spriteHeight); _drawRect = new Rectangle(0, 0, spriteWidth, spriteHeight); Velocity = Vector2.Zero; _textureRects = new Rectangle[numStates,numFrames]; for (int i = 0; i < numStates; i++) { for (int j = 0; j < numFrames; j++) { _textureRects[i,j] = new Rectangle(i * spriteWidth, j * spriteHeight, spriteWidth, spriteHeight); } } _animationInterval = animationTime; _tillNextFrame = _animationInterval; _currentFrame = 0; _numFrames = numFrames; _spriteState = SpriteState.FacingLeft; }
public void SetCurrentAnimationState(string name) { foreach(SpriteState state in _animationStates ) { if (state.name == name) { _currentState = state; _currentState.currentFrame = 0; animationCycles = 0; previousCurrentFrame = 0; break; } } }
public void AddAnimationState(SpriteState state) { _animationStates.Add(state); }
void Awake() { UnitSprite = GetComponentInChildren<SpriteRenderer>(); CurrentInitiative = Mathf.Max(Random.Range(1, 20) + 20 - InitiativeModifier, 0); CurrentHealth = MaximumHealth; Spells = new List<Spell>(); foreach(string curSpell in SpellNameStrings) { Spells.Add(SpellLibrary.GetSpellByName(curSpell)); } UnitSpriteSet = SpriteSetLibrary.GetSpriteSetByName(_UnitSpriteSetString); CurrentSpriteState = SpriteState.Idle; HurtFrame = 0; WorldMaker.Units.Add(this); }
public void Resume() { state = SpriteState.PLAYED; // Just play from previous frame--> do nothing }
/// <summary> /// Frame Renewal /// </summary> /// <param name="gameTime"></param> public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { base.Update(gameTime); for (Int32 i = 0; i < _blocks.Length; i++) { _blocks[i].Update(gameTime); _blocks[i].Position = this.Position + Vector2.UnitX * 20 * (i % 3) + Vector2.UnitY * (20 * (i / 3)); _blocks[i].Color = this.Color; } // Update opacity this.Color = Color.Lerp(this.Color, this.CurrentState == SpriteState.TransitionOff ? Color.Transparent : Color.White, (Single)gameTime.ElapsedGameTime.TotalSeconds * 5); if (this.CurrentState == SpriteState.TransitionOff) { if (this.Color.A < 5) { this.CurrentState = SpriteState.Hidden; this.Enabled = false; } } }
public void Pause() { state = SpriteState.PAUSED; }
public void Update(GameTime gameTime) { if (Velocity.X > 0) _spriteState = SpriteState.FacingRight; if (Velocity.X < 0) _spriteState = SpriteState.FacingLeft; if (_moving) { _tillNextFrame -= gameTime.ElapsedGameTime; if (_tillNextFrame < TimeSpan.Zero) { _currentFrame = (_currentFrame + 1) % _numFrames; _tillNextFrame = _animationInterval; } } else { _currentFrame = 0; } _moving = false; }
public void Play() { // Reset to first frame if (state != SpriteState.PLAYED) { state = SpriteState.PLAYED; this.nextFrame = DEFAULT_FRAME; } }
/// <summary> /// Updates the alert /// </summary> /// <param name="gameTime"></param> public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { base.Update(gameTime); if (!this.Enabled) return; _alertTime += (Single)gameTime.ElapsedGameTime.TotalSeconds; // Update opacity this.Color = Color.Lerp(this.Color, this.CurrentState == SpriteState.TransitionOff ? Color.Transparent : Color.White, (Single)gameTime.ElapsedGameTime.TotalSeconds * 5); // Kill transition if (_alertTime > MaxAlertTime) { this.CurrentState = SpriteState.TransitionOff; if (this.Color.A < 5) { this.CurrentState = SpriteState.Hidden; this.Enabled = false; this.Visible = false; this.OnFinished.Invoke(this, EventArgs.Empty); } } }
/// <summary> /// Initializes alert (activates) /// </summary> public override void Initialize() { base.Initialize(); _alertTime = 0; this.Enabled = true; this.Visible = true; this.CurrentState = SpriteState.Active; }
public void ChangeSpriteState() { _state = OtherState(); }
/// <summary> /// Exit sprite (go to off transit) /// </summary> public void Exit() { this.CurrentState = SpriteState.TransitionOff; }
void FollowPath() { CurrentSpriteState = SpriteState.Walk; transform.position = Vector3.MoveTowards(transform.position, WalkPath.Tiles[0].WorldPosition, WalkSpeed); Facing = Knowledge.FacingToTile(CurrentTile, WalkPath.Tiles[0]); if(Vector3.Distance(transform.position, WalkPath.Tiles[0].WorldPosition) <= .05f) { WarpToTile(WalkPath.Tiles[0]); WalkPath.Tiles.RemoveAt(0); if(WalkPath.Tiles.Count == 0) { WalkPath = null; CurrentSpriteState = SpriteState.Idle; RoundManager.FinishedAnimation(); } } }
/// <summary> /// Initialzes jup info /// </summary> public override void Initialize() { base.Initialize(); foreach (var block in _blocks) block.Initialize(); this.CurrentState = SpriteState.Active; this.PointsInfoVisible = !true; this.BlocksInfoVisible = !false; }
void CastSpellFrame(Spell toCast, int index) { this.CurrentSpriteState = toCast.SpellAnimation.Frames[index].State; List<Unit> AffectedUnits = new List<Unit>(); if (SpellTargetTile.OccupyingUnit != null) { AffectedUnits.Add(SpellTargetTile.OccupyingUnit); } foreach (Unit curUnit in AffectedUnits) { curUnit.TakeDamageFromSpell(this, FollowingSpell, index); } }
void FollowSpellAnimation() { if(FollowingSpell.SpellAnimation.Frames.Count > AnimationFrame) { AnimationTimer += Time.deltaTime; if (AnimationTimer >= FollowingSpell.SpellAnimation.Frames[AnimationFrame].FrameDuration) { AnimationTimer = 0; AnimationFrame++; if (FollowingSpell.SpellAnimation.Frames.Count > AnimationFrame) { CastSpellFrame(FollowingSpell, AnimationFrame); } else { FollowingSpell = null; SpellTargetTile = null; CurrentSpriteState = SpriteState.Idle; if (RoundManager.ActiveUnit == this) { RoundManager.FinishedAnimation(); } } } } }
public void Stop() { state = SpriteState.STOPPED; // Stop and reset frame to first frame this.nextFrame = DEFAULT_FRAME; }