public void Action() { if (!this.HasCollidedInspect || this.Crouching) { return; } this.savedCollidedInspect = this.collidedInspect; var collidedInspectScript = this.savedCollidedInspect.GetComponent <Inspect>(); if (collidedInspect.tag == "Inspect") { if (collidedInspectScript.CrouchType) { AnimatorUtils.PlayOnce(this.animator, "StartCrouch"); } else { collidedInspectScript.StartSpeech(this.speechScript, this.SpeechName + ":"); } } else if (collidedInspect.tag == "Entry") { var entryScript = collidedInspect.GetComponent <Entry>(); if (entryScript != null && entryScript.Enabled && !entryScript.IsTrigger) { this.EnterRoom(entryScript); } } }
private void UpdateAnimation() { if (this.Crouching || (!this.Moving && this.Thinking)) { this.idleCount = 0; return; } if (this.Moving && this.Running) { this.idleCount = 0; AnimatorUtils.PlayOnce(this.animator, "Run"); } else if (this.Moving) { this.idleCount = 0; AnimatorUtils.PlayOnce(this.animator, "Walk"); } else { AnimatorUtils.PlayOnce(this.animator, "Idle"); } }
private IEnumerator ScrambleBoardIfNecessary(Board board, int attempts = 0) { if (attempts >= 5) { foreach (Tile tile in board.Tiles) { if (tile.HasContents) { GameObject contents = tile.PushContents(null); AnimatorUtils.Trigger(contents, "Matched"); } } yield return(new WaitForSeconds(1.5f)); yield return(FillBoard(board)); } if (BoardHasNoMatches(board)) { yield return(new WaitForSeconds(1.5f)); yield return(ScrambleBoard(board)); yield return(ScrambleBoardIfNecessary(board, attempts + 1)); } }
public void Action(List <Tile> tiles, Action callback = null, bool free = false, List <SkillModifier> mods = null, bool animation = true) { if (mods != null) { skillModifiers = mods; } if (tiles.Count > 0) { boardEntity.SetAnimationDirection(AnimatorUtils.GetAttackDirectionCode(boardEntity.GetTile().Position, tiles[0].Position)); if (animationType != AnimatorUtils.animationType.none && animation) { boardEntity.SetAnimation(animationType); } } SkillReport report = ActionHelper(tiles); if (report != null) { foreach (Tuple <Stats, Stats> stat in report.targets) { foreach (Passive p in ((CharacterBoardEntity)stat.first.BoardEntity).Passives) { p.AttackedBy(boardEntity); } } } ActionHelperNoPreview(tiles, () => previewCallback(report, free, tiles, callback)); }
public override IEnumerator ProcessMatch(List <MatchPiece> matches, List <Tile> matchTiles, Board board) { bool destroyedFire = false; var adjacentTiles = board.GetAdjacentTiles(matchTiles, false); foreach (Tile tile in adjacentTiles) { if (!tile.HasContents) { continue; } MatchPiece piece = tile.Contents.GetComponent <MatchPiece>(); if (piece.Matches(typeof(FirePiece))) { tile.PushContents(null); if (!AnimatorUtils.Trigger(piece.gameObject, "DestroyWithWater")) { Destroy(piece.gameObject); } destroyedFire = true; } } if (destroyedFire) { AudioManager.Instance.PlaySound("DestroyWithWater"); yield return(new WaitForSeconds(destroyFireWaitTime)); } bool bloomed = false; foreach (Tile tile in adjacentTiles) { if (!tile.HasContents) { continue; } MatchPiece piece = tile.Contents.GetComponent <MatchPiece>(); if (piece.Matches(typeof(SeedPiece))) { var flowerPrefab = ((SeedPiece)piece).FlowerPrefab.gameObject; tile.PushContentsFromPrefab(flowerPrefab); if (!AnimatorUtils.Trigger(piece.gameObject, "Bloom")) { Destroy(piece.gameObject); } bloomed = true; } } if (bloomed) { AudioManager.Instance.PlaySound("BloomWithWater"); yield return(new WaitForSeconds(bloomWaitTime)); } }
public static void drawAnimationDescriptions(Editor editor, AnimatorUtils animUtils) { for (int descIdx = 0; descIdx < animUtils.DescriptionTexts.Length; ++descIdx) if (animUtils.descEntries[descIdx].array.Length == 1) drawAnimPopup(animUtils.DescriptionTexts[descIdx], ref animUtils.descEntries[descIdx].array[0].index, animUtils.AnimationNames, ref animUtils.descEntries[descIdx].array[0].animationName); else for (int i = 0; i < animUtils.descEntries[descIdx].array.Length; ++i) drawAnimPopup(animUtils.DescriptionTexts[descIdx] + " " + (i + 1), ref animUtils.descEntries[descIdx].array[i].index, animUtils.AnimationNames, ref animUtils.descEntries[descIdx].array[i].animationName); }
public virtual void ensureDataConsistency() { if (impactInfo == null) impactInfo = new ImpactInfo(); animUtils = GetComponent<AnimatorUtils>() ?? gameObject.AddComponent<AnimatorUtils>(); animUtils.setTextsDelegate(getDescriptionTexts); animUtils.DescriptionEditingAllowed = false; }
IEnumerator OnTileClickedCoroutine(Board board, Tile tile) { try { if (tile.HasContents && RemainingTurns > 0) { List <Tile> matchTiles = GetAdjacentMatches(board, tile, true); List <MatchPiece> matches = (from match in matchTiles select match.Contents.GetComponent <MatchPiece>()) .ToList(); if (matches.Count < minimumMatches || !matches[0].CanMatch) { matches.ForEach(match => AnimatorUtils.Trigger(match.gameObject, "NoMatch")); AudioManager.Instance.PlaySound("NoMatch"); yield break; } AudioManager.Instance.PlaySound("Match"); ChangeRemainingTurns(-1, false); matches.ForEach(match => { AnimatorUtils.Trigger(match.gameObject, "IsMatching"); }); yield return(new WaitForSeconds(waitBeforeProcessingMatch)); yield return(matches[0].ProcessMatch(matches, matchTiles, board)); ChangeScore(matches[0].ScoreMatch(matches)); matchTiles.ForEach(matchedTile => { GameObject piece = matchedTile.PushContents(null); if (!AnimatorUtils.Trigger(piece, "Matched")) { Destroy(piece); } }); yield return(FillBoard(board)); if (RemainingTurns <= 0) { EndGame(); } } } finally { board.Unlock(); } }
public void Block() { if (HasContents) { Animator animator = contents.GetComponent <Animator>(); if (animator && AnimatorUtils.HasParameter("Blocked", animator)) { animator.SetTrigger("Blocked"); } } }
public static bool Trigger(GameObject gameObject, string trigger) { Animator animator = gameObject.GetComponent <Animator>(); if (animator && AnimatorUtils.HasParameter(trigger, animator)) { animator.SetTrigger(trigger); return(true); } return(false); }
void Update() { if (HasContents) { Animator animator = contents.GetComponent <Animator>(); if (animator && AnimatorUtils.HasParameter("IsMoving", animator)) { animator.SetBool("IsMoving", !IsContentCentered()); } } }
public static bool SetBool(GameObject gameObject, string parameter, bool value) { Animator animator = gameObject.GetComponent <Animator>(); if (animator && AnimatorUtils.HasParameter(parameter, animator)) { animator.SetBool(parameter, value); return(true); } return(false); }
/// <summary> /// The animator implementation. /// </summary> override protected void DoAnimation(float speedFactor) { // get current fade step, and if done, skip float position = AnimatorUtils.CalcTransitionPercent(TimeAnimated, FadingTime); // calc current alpha value float alpha = (FromAlpha * (1f - position)) + (ToAlpha * position); // update renderables foreach (var renderable in ModelRenderables) { renderable.MaterialOverride.Alpha = alpha; } }
private void IncreaseIdleCount() { if (this.LongIdleWaitCount == 0) { return; } this.idleCount++; if (this.idleCount >= this.LongIdleWaitCount) { AnimatorUtils.PlayOnce(this.animator, "SThink"); } }
/// <summary> /// 播放设置bool值的动画 /// </summary> /// <param name="animator">动画组件</param> /// <param name="name">动作名称</param> public static void playBoolAnimal(Animator animator, string name) { if (AnimatorUtils.isName(animator, name)) { return; } int length = animator.parameters.Length; for (int i = 0; i < length; ++i) { animator.SetBool(animator.parameters[i].name, false); } animator.SetBool(name, true); }
private void ChangeTarget() { // we gotta check to see if we just walked into a taunt, we will have to do this for stun as well /*if (GetTauntTiles().Count != 0) * { * HashSet<Tile> tauntTiles = GetTauntTiles(); * for(int a = 0; a < path.Count; a++) * { * if (tauntTiles.Contains(path[a])) * { * path.RemoveRange(a, path.Count - a); * interupted = true; * } * } * } */ if (path.Count > 0) { AnimatorUtils.animationDirection dir = AnimatorUtils.GetAttackDirectionCode(GetTile().Position, path[0].Position); if (!pushing) { SetAnimationDirection(dir); } target = path[0]; path.RemoveAt(0); pathCounter++; if (charging) { Position targetTile = position + direction; Tile t = tileManager.GetTile(targetTile); if (t != null && t.BoardEntity != null && t.BoardEntity.Team != Team) { chargeCounter++; Tile newTile = tileManager.GetTile(targetTile + direction); AnimatorUtils.animationDirection pushDir = AnimatorUtils.GetAttackDirectionCode(newTile.Position, position); ((CharacterBoardEntity)t.BoardEntity).ExecutePush(newTile, pushDir); } } } else { bool display = team == Team.Player; if (!charging) { stats.SubtractMovementPoints(pathCounter, display); } if (interuptClearMovement) { stats.SetMutableStat(AttributeStats.StatType.Movement, 0); stats.SetMutableStat(AttributeStats.StatType.AP, 0); interuptClearMovement = false; } // all done moving target = null; PathOnClick.pause = false; OutlineOnHover.disabled = false; if (characterAnimation != null) { SetAnimation(AnimatorUtils.animationType.idle); } if (moveDoneCallback != null) { Action <bool> tempMoveDoneCallback = moveDoneCallback; moveDoneCallback = null; tempMoveDoneCallback(interupted); } if (charging) { Position targetTile = position + direction; Tile t = tileManager.GetTile(targetTile); if (t != null && t.BoardEntity != null && t.BoardEntity.Team != Team) { chargeCallback(chargeCounter, Core.Instance.convert(t.BoardEntity)); } else { chargeCallback(chargeCounter, null); } charging = false; } } }
public void PlayStopCrouchAnimation() { AnimatorUtils.PlayOnce(this.animator, "StopCrouch"); }
void OnEnable() { animUtils = target as AnimatorUtils; animUtils.ensureDataConsistency(); }