void Start() { _moveData = GetComponent<MoveData>(); _dir = StartWalkingRight ? 1 : -1; _currentSpeed = PatrolSpeed; _counter = WalkCycleFrames - WalkCycleOffset; _pauseCounter = PauseFramesOffset; }
private void _Move(MoveData data) { _Speed = data.Speed; _Direction = new Vector2(data.VectorX, data.VectorY); var pos = new Vector2(data.FirstX , data.FirstY); gameObject.transform.position = new Vector3(pos.x , 0 ,pos.y); }
public override void StartAI() { MoveData_FlyingToLandingAirSpot = this.unit.MoveDataDict[MoveDataName_FlyingToLandingAirSpot]; MoveData_LandingFromAirSpot = this.unit.MoveDataDict[MoveDataName_LandingFromAirSpot]; applicableWaypoints = WayPoint.GetWaypoints(ApplicableWaypointName); unit.CurrentAI = this; StartCoroutine("Start_LandingBehavior"); this.enabled = true; }
public MoveController(int num) { _data = new MoveData(); _dirty = true; gemState = new PSMoveSharpGemState(); sphereState = new PSMoveSharpSphereState(); imageState = new PSMoveSharpImageState(); Connected = false; Num = num; }
void Start() { _move = GetComponent<MoveData>(); _rigidBody = GetComponent<Rigidbody>(); //_animator = GetComponent<Animator>(); _groundLayerMask = 1 << 8; float initialRotation = Mathf.Round(transform.rotation.eulerAngles.y); _move.MoveAngle = initialRotation; facingAngle = -initialRotation; _moveDir = getVectorFromAngle(initialRotation); }
public WalkingThought(IMover mover, MoveData data) { _mover = mover; _data = data; }
/// <summary> /// Call this routine to start navigation. /// Target - the target navigate to /// IsMovingTarget - Is the target a static target? If yes, the path wouldn't be refreshed during navigation /// MoveData - the moving data(animations, speed) /// </summary> /// <param name="target"></param> /// <param name="IsMovingTarget"></param> public override void StartNavigation(Transform target, bool IsMovingTarget, MoveData MoveData) { FindPath(target); //If IsMovingTarget = false, means the target is static, no need to auto refresh path AutoRefreshPath = IsMovingTarget; NaivgateToTarget = target; NavigationMoveData = MoveData; }
public MoveData GetMoveDataFromEnum(PSXAPI.Response.Payload.PokemonMoveID id) { MoveData result = Moves.ToList().Find(move => move.BattleID.ToLowerInvariant() == id.ToString().ToLowerInvariant()); return(result); }
public override int GetCost(MoveData moveData) { return(moveData.diagonal ? moveTicksDiagonal : moveTicksCardinal); }
public void Validate(MoveData move) { ValidateStartCoordinate(move); ValidateEndCoordinate(move); }
//This has to be called after immunities, setting zbroke protect and all of the tryhit and movehit things int GetDamage(Pokemon target) { MoveData moveData = activeData.moveData; Battle.RelayVar relayVar; /*RETURN DIRECT DAMAGE*/ if (moveData.ohko != Globals.OHKO.Null) { return(target.maxhp); //Fissure, Sheer cold } if (moveData.eventMethods.damageCallback != null) //mirro coat, naturesmaddnes, hyper fang... { relayVar = new Battle.RelayVar(); moveData.eventMethods.StartCallback("damageCallback", battle, relayVar, target.targetData, source, null); return(relayVar.integerValue); } if (moveData.damageByLevel) { return(activeData.pokemonLevel); //nightshade, seismic toss } if (moveData.damage != -1) { return(moveData.damage); //Dragon rage, sonic boom } /*USING BASE POWER*/ //Category Globals.MoveCategory category = (moveData.category == Globals.MoveCategory.Null) ? Globals.MoveCategory.Physical : moveData.category; if (moveData.defensiveCategory == Globals.MoveCategory.Null) { category = moveData.defensiveCategory; } //BasePower int basePower = activeData.basePower; if (moveData.eventMethods.basePowerCallback != null) { relayVar = new Battle.RelayVar(); moveData.eventMethods.StartCallback("basePowerCallback", battle, relayVar, target.targetData, source, moveData); basePower = relayVar.integerValue; } if (basePower < 0) { return(-1); //Return -1 means no dealing damage } basePower = Mathf.Max(1, basePower); //Min value will be 1 //CritRatio int[] critMultiplier = { 0, 24, 8, 2, 1 }; relayVar = new Battle.RelayVar(integerValue: moveData.critRatio); relayVar = battle.RunEvent("ModifyCritRatio", source.targetScript, target.myPokemon, moveData, relayVar); int critRatio = Mathf.Clamp(relayVar.integerValue, 0, 4); //Set crit activeData.crit = moveData.willCrit; if (!activeData.crit) { activeData.crit = RandomScript.RandomChance(1, critMultiplier[critRatio]); } if (activeData.crit) { relayVar = new Battle.RelayVar(booleanValue: activeData.crit); relayVar = battle.RunEvent("CriticalHit", target.targetData, null, moveData); activeData.crit = relayVar.booleanValue; } //Happens after crit calculation relayVar = new Battle.RelayVar(integerValue: basePower); relayVar = battle.RunEvent("BasePower", source.targetScript, target.myPokemon, moveData, relayVar, true); if (relayVar.getEndEvent() && relayVar.integerValue != -1) { return(0); } basePower = Mathf.Max(1, relayVar.integerValue); //Starting? int level = activeData.pokemonLevel; Pokemon defender = target; string attackStat = (category == Globals.MoveCategory.Physical) ? "Atk" : "SpA"; string defenseStat = (category == Globals.MoveCategory.Physical) ? "Def" : "SpD"; //statTable int attack; int defense; int atkBoosts = (moveData.useTargetOffensive) ? defender.boosts.GetBoostValue(attackStat) : activeData.pokemonBoosts.GetBoostValue(attackStat); int defBoosts = (moveData.useSourceDefensive) ? activeData.pokemonBoosts.GetBoostValue(defenseStat) : defender.boosts.GetBoostValue(defenseStat); bool ignoreNegativeOffensive = moveData.ignoreNegativeOffensive; bool ignorePositiveDefensive = moveData.ignorePositiveDefensive; if (activeData.crit) { ignoreNegativeOffensive = true; ignorePositiveDefensive = true; } bool ignoreOffensive = moveData.ignoreOffensive || (ignoreNegativeOffensive && atkBoosts < 0); bool ignoreDefensive = moveData.ignoreDefensive || (ignorePositiveDefensive && defBoosts > 0); if (ignoreOffensive) { //this.debug('Negating (sp)atk boost/penalty.'); atkBoosts = 0; } if (ignoreDefensive) { //this.debug('Negating (sp)def boost/penalty.'); defBoosts = 0; } if (moveData.useTargetOffensive) { attack = defender.CalculateStat(attackStat, atkBoosts); } else { attack = CalculateMoveStat(attackStat, atkBoosts); } if (moveData.useSourceDefensive) { defense = CalculateMoveStat(defenseStat, defBoosts); } else { defense = defender.CalculateStat(defenseStat, defBoosts); } //Apply stat modifiers relayVar = new Battle.RelayVar(integerValue: attack); relayVar = battle.RunEvent("Modify" + attackStat, source.targetScript, defender.myPokemon, moveData, relayVar); attack = relayVar.integerValue; relayVar = new Battle.RelayVar(integerValue: defense); relayVar = battle.RunEvent("Modify" + defenseStat, defender.targetData, source, moveData, relayVar); defense = relayVar.integerValue; //int(int(int(2 * L / 5 + 2) * A * P / D) / 50); int baseDamage = Mathf.FloorToInt(Mathf.FloorToInt(Mathf.FloorToInt(2f * level / 5f + 2f) * basePower * attack / defense) / 50f); return(ModifyDamage(baseDamage, target)); }
void Start() { _move = GetComponent<MoveData>(); _movement = GetComponent<Movement>(); }
void ResolveDamagingAttack(MoveData move, MonBattleData attacker, MonBattleData defender) { bool crit; Effectiveness effectiveness; int damage; if (attacker == playerMon) { playerModel.GetComponent <Animator>().SetTrigger("Attack"); } else { enemyModel.GetComponent <Animator>().SetTrigger("Attack"); } if (CheckIfHit(move, attacker, defender)) { crit = CheckIfCrit(move); effectiveness = defender.GetEffectiveness(move.moveType); damage = CalculateDamage(move, attacker, defender, crit); if (crit) { battleDialogue.AddToMessages("A critical hit!"); } if (effectiveness == Effectiveness.resist2x || effectiveness == Effectiveness.resist4x) { battleDialogue.AddToMessages("It's not very effective..."); } else if (effectiveness == Effectiveness.weak2x || effectiveness == Effectiveness.weak4x) { battleDialogue.AddToMessages("It's super effective!!!"); } if (effectiveness == Effectiveness.immune) { battleDialogue.AddToMessages("It had no effect..."); } defender.TakeDamage(damage); if (defender == playerMon) { playerModel.GetComponent <Animator>().SetTrigger("Damage"); } else { enemyModel.GetComponent <Animator>().SetTrigger("Damage"); } if (move.causesStatus != StatusEffect.none) { ResolveStatus(move, defender); } if (move.statToChange != MonStat.none) { if (move.affectSelf) { ResolveStatChange(move, attacker); } else { ResolveStatChange(move, defender); } } UpdateHPBar(defender); UpdateHPBar(attacker); } else { battleDialogue.AddToMessages("But it missed!"); } }
public void Update(ref MoveData moveData) { moveData.position += moveData.forward * Time.deltaTime * moveData.speed; }
public void SetCanMove(ref MoveData moveData, bool canMove) { moveData.movable = canMove; }
public Vector3 GetPosition(ref MoveData moveData) { return(moveData.position); }
/// <summary>Meminta AI untuk generate move.</summary> private IEnumerator MakeEngineMove(Board board) { if (whiteTurnToMove) { GameState.totalTurn++; } GameState.stopwatch.Restart(); MoveData move = null; if (GameState.boardMode == GameState.BoardMode.AlphaBetaVSAlphaBeta) { if (whiteTurnToMove) { move = engine.makeMoveAlphaBeta(board, whiteTurnToMove, GameState.whiteSearchDepth); } else { move = engine.makeMoveAlphaBeta(board, whiteTurnToMove, GameState.blackSearchDepth); } } else if (GameState.boardMode == GameState.BoardMode.AlphaBetaVSKillerHeuristic) { if (whiteTurnToMove) { move = engine.makeMoveAlphaBeta(board, whiteTurnToMove, GameState.whiteSearchDepth); } else { move = engine.makeMoveKillerHeuristic(board, whiteTurnToMove, GameState.blackSearchDepth); } } else if (GameState.boardMode == GameState.BoardMode.KillerHeuristicVSAlphaBeta) { if (whiteTurnToMove) { move = engine.makeMoveKillerHeuristic(board, whiteTurnToMove, GameState.whiteSearchDepth); } else { move = engine.makeMoveAlphaBeta(board, whiteTurnToMove, GameState.blackSearchDepth); } } else if (GameState.boardMode == GameState.BoardMode.KillerHeuristicVSKillerHeuristic) { if (whiteTurnToMove) { move = engine.makeMoveKillerHeuristic(board, whiteTurnToMove, GameState.whiteSearchDepth); } else { move = engine.makeMoveKillerHeuristic(board, whiteTurnToMove, GameState.blackSearchDepth); } } GameState.stopwatch.Stop(); PerformMove(move); UpdateStatus(); writeLog(move); whiteTurnToMove = abstractBoard.whiteTurn; doneMove = true; yield return(null); }
public string getNotation(Board disambiguationBoard, MoveData move) { string str = ""; int type = Mathf.Abs(move.pieceType); if (type == (int)PieceData.PieceType.WhitePawn && move.capturedType != (int)PieceData.PieceType.None) { str += Board.SquareNames[move.from].Substring(0, 1); } else if (type == (int)PieceData.PieceType.WhiteRook) { str += "R"; } else if (type == (int)PieceData.PieceType.WhiteKnight) { str += "N"; } else if (type == (int)PieceData.PieceType.WhiteBishop) { str += "B"; } else if (type == (int)PieceData.PieceType.WhiteQueen) { str += "Q"; } else if (type == (int)PieceData.PieceType.WhiteKing && move.moveType != MoveData.MoveType.Castle) { str += "K"; } // periksa apakah ada move yang ambigu (contoh: 2 kuda yang dapat melangkah ke tempat yang sama) if (type != (int)PieceData.PieceType.WhitePawn && type != (int)PieceData.PieceType.WhiteKing) { List <MoveData> otherMoves = disambiguationBoard.findLegalMoves(disambiguationBoard.whiteTurn); List <MoveData> ambiguousMoves = new List <MoveData>(); foreach (MoveData otherMove in otherMoves) { if (otherMove.to == move.to && otherMove.from != move.from && otherMove.pieceType == move.pieceType) { ambiguousMoves.Add(otherMove); } } if (ambiguousMoves.Count > 0) { bool fileMatch = false; // kolom sama (a-h) bool rankMatch = false; // baris sama (1-8) foreach (var ambiguousMove in ambiguousMoves) { if (Board.SquareNames[ambiguousMove.from].Substring(0, 1) == Board.SquareNames[move.from].Substring(0, 1)) { fileMatch = true; } if (Board.SquareNames[ambiguousMove.from].Substring(1, 1) == Board.SquareNames[move.from].Substring(1, 1)) { rankMatch = true; } } if (!fileMatch) { str += Board.SquareNames[move.from].Substring(0, 1); } else if (fileMatch && !rankMatch) { str += Board.SquareNames[move.from].Substring(1, 1); } else if (fileMatch && rankMatch) { str += Board.SquareNames[move.from]; } } } // menyerang piece lawan if (move.capturedType != (int)PieceData.PieceType.None) { str += "x"; } if (move.moveType == MoveData.MoveType.Castle) // castling move { if (move.to == 2 || move.to == 58) // long castle { str += "O-O-O"; } else // short castle { str += "O-O"; } } else { str += Board.SquareNames[move.to]; if (move.moveType == MoveData.MoveType.EnPassant) { str += "e.p."; } } if (move.promoted) { str += "=Q"; } if (GameState.boardStatus == GameState.Status.Check) { str += "+"; } else if (GameState.boardStatus == GameState.Status.Checkmate) { str += "#"; } return(str); }
public void HighlightMove(Pokemon.Moveslot moveslot) { BTLUI_ButtonFight selectedBtn = null; if (move1Btn.moveslot != null) { if (move1Btn.moveslot == moveslot) { selectedBtn = move1Btn; } else { move1Btn.UnselectSelf(); } } if (move2Btn.moveslot != null) { if (move2Btn.moveslot == moveslot) { selectedBtn = move2Btn; } else { move2Btn.UnselectSelf(); } } if (move3Btn.moveslot != null) { if (move3Btn.moveslot == moveslot) { selectedBtn = move3Btn; } else { move3Btn.UnselectSelf(); } } if (move4Btn.moveslot != null) { if (move4Btn.moveslot == moveslot) { selectedBtn = move4Btn; } else { move4Btn.UnselectSelf(); } } if (selectedBtn != null) { selectedBtn.SelectSelf(); backBtn.UnselectSelf(); MoveData moveData = selectedBtn.moveData; TypeData typeData = TypeDatabase.instance.GetTypeData(moveData.moveType); Color typeColor = Color.clear; ColorUtility.TryParseHtmlString(typeData.typeColor, out typeColor); string moveText = "<color=" + typeData.typeColor + ">" + typeData.typeName + "</color>\n"; moveText += moveData.category.ToString() + " / "; moveText += (moveData.basePower > 0) ? moveData.basePower + " BP / " : ""; moveText += (moveData.accuracy > 0) ? (Mathf.FloorToInt(moveData.accuracy * 100)) + "% ACC" : "Never Misses"; promptText.text = moveText; } }
// Playing a Princess or not playing a Countess when you have a Prince/King will result in instantly losing the round // Such moves should not even be considered protected bool IsMoveSuicidal(MoveData move, CardController otherCard) { return(CardController.IsKnockOutByPrincess(move.Card.Value, otherCard.Value, move.Player == move.Target) || CardController.IsKnockOutByCountess(move.Card.Value, otherCard.Value)); }
public abstract void StartNavigation(Transform target, bool IsMovingTarget, MoveData MoveData);
// Returns whether the move under consideration looks stupid or not protected bool IsMoveStupid(MoveData move, CardController otherCard) { // Penalize playing against the human playing before they had a first turn after launching a game if (move.Target == Game.HumanPlayer && !MyPerceptor.HumanPlayerHasActed) { return(true); } // Playing anything against a player protected by a Handmaid looks stupid if (move.Target != null && move.Target.Protected) { return(true); } // NOT playing your hand when someone else knows your hand and there are still Guards in play if (MyPerceptor.SomeoneKnowsMyHand && move.Card != myHand && move.Card.Value != otherCard.Value && move.Card.Value != CardController.VALUE_HANDMAID && MyPerceptor.GetRevealedCardCount(CardController.VALUE_GUARD) < GameController.CARD_COUNT[CardController.VALUE_GUARD]) { return(true); } // Playing the higher card in the very last round if (MyPerceptor.RemainingDeckSize <= 1 && move.Card.Value > otherCard.Value) { return(true); } // Otherwise, it depends on the type of card switch (move.Card.Value) { case CardController.VALUE_GUARD: // Guessing a card when all cards of that value are either on the discard pile, or in your own hand if (MyPerceptor.GetRevealedCardCount(move.TargetHandGuess) >= GameController.CARD_COUNT[move.TargetHandGuess]) { return(true); } else if (MyPerceptor.GetCertainHandValue(move.Target) != move.TargetHandGuess && KnowAtLeastOneOtherHand) { // Playing a Guard against a player whose hand you don't know when you know someone else's hand return(true); } return(false); case CardController.VALUE_PRIEST: // Playing a Priest against a player whose hand you already know return(MyPerceptor.GetCertainHandValue(move.Target) > 0); case CardController.VALUE_BARON: // Playing a Baron when your other card is a guard is stupid, period if (otherCard.Value == CardController.VALUE_GUARD) { return(true); } else if (otherCard.Value < MyPerceptor.GetCertainHandValue(move.Target)) { // Playing a Baron against a player who you know has as higher hand return(true); } return(false); case CardController.VALUE_PRINCE: // Playing a Prince against yourself in general if (move.Target == this) { return(true); } else { // Playing a Prince against anyone else when you know who has the Princess int hasThePrincess = WhoHasThePrincess; return(hasThePrincess >= 0 && move.Target.SittingOrder != hasThePrincess); } case CardController.VALUE_KING: // Playing a King when your other card is a guard is just handing them the key to knock you out if (otherCard.Value == CardController.VALUE_GUARD) { return(true); } else { // Playing a King against anyone who will have a chance to knock you out bool thereAreStillGuardsInPlay = (MyPerceptor.GetRevealedCardCount(CardController.VALUE_GUARD) < GameController.CARD_COUNT[CardController.VALUE_GUARD]); return(MyPerceptor.WillThisPlayerHaveAnotherTurn(move.Target) && thereAreStillGuardsInPlay); } default: return(false); } }
public override MoveData.DualUtility EstimateMoveUtility(MoveData move, CardController otherCard, AIGenericPerceptor perceptorData) { Debug.Assert(move.Card == this); // The utility of playing the Princess is always negative, because it is an instant loss return(MoveData.DualUtility.MinValue); }
/// <summary> /// Start behave attack /// </summary> /// <param name="behavior"></param> /// <returns></returns> public virtual IEnumerator Start_Attack(AIBehavior behavior) { AttackData attackData = null; float lastScanEndConditionTime = Time.time; while (true) { //If no target is found, do nothing if (Halt || CurrentTarget == null) { yield return(null); continue; } //Get attack data if (behavior.UseRandomAttackData == false) { attackData = Unit.AttackDataDict[behavior.AttackDataName]; } else { string attackDataName = Util.RandomFromArray <string>(behavior.AttackDataNameArray); attackData = Unit.AttackDataDict[attackDataName]; } //if this behavior's end condition matches, end this behavior if ((Time.time - lastScanEndConditionTime) >= behavior.AlterBehaviorInterval) { lastScanEndConditionTime = Time.time; if (CheckAlternateBehaviorCondition(behavior)) { break; } } //Animating attack string AttackAnimationName = attackData.AnimationName; //If can see target, and target distance <= AttackableRange, do this: //1. Face to target //2. Check last attack time against attack interval //3. if #2 pass, animating, send hit message if (this.CanSeeCurrentTarget && CurrentTargetDistance <= attackData.AttackableRange) { if (attackData.LookAtTarget) { transform.LookAt(new Vector3(CurrentTarget.position.x, transform.position.y, CurrentTarget.position.z)); } //If hitTriggerType is HitTriggerType.ByAnimationEvent, the function will be invoked by animation event if (attackData.hitTriggerType == HitTriggerType.ByTime) { SendMessage("_Attack", attackData.Name); } animation.CrossFade(attackData.AnimationName); yield return(new WaitForSeconds(animation[attackData.AnimationName].length)); //If AttackInterrupt = true, means wait for a while, so execute the IdleData if (behavior.AttackInterrupt) { IdleData idleData = this.Unit.IdleDataDict[behavior.IdleDataName]; float interval = Random.Range(behavior.AttackIntervalMin, behavior.AttackIntervalMax); animation.CrossFade(idleData.AnimationName); yield return(new WaitForSeconds(interval)); animation.Stop(idleData.AnimationName); } else { yield return(null); } continue; } //else if can't see target, navigating until CanSeeCurrentTarget = true & within AttackableRange else { MoveData moveData = Unit.MoveDataDict[behavior.MoveDataName]; yield return(StartCoroutine(NavigateToTransform(CurrentTarget, moveData, attackData.AttackableRange, 1))); continue; } yield return(null); } animation.Stop(attackData.AnimationName); StopBehavior(behavior); }
public void ReSetData(string moveId) { this.moveId = moveId; this.moveData = Moves.BattleMovedex[moveId].DeepCopy(); }
/// <summary> /// Call this routine to start navigation. /// Target - the target navigate to /// IsMovingTarget - Is the target a static target? If yes, the path wouldn't be refreshed during navigation /// MoveData - the moving data(animations, speed) /// </summary> /// <param name="target"></param> /// <param name="IsMovingTarget"></param> public void StartNavigation(Transform target, bool IsMovingTarget, MoveData MoveData) { navigator.StartNavigation(target, IsMovingTarget, MoveData); }
public void Setup() { _moveLookups = new MoveData(); }
void OnGUI() { // Sample move data moves.Clear(); foreach (var selected in Selection.objects) { var path = AssetDatabase.GetAssetPath(selected); if (!AssetDatabase.IsValidFolder(path)) { continue; } var moveData = new MoveData(); moveData.assetFolderStartPath = path; moveData.assetFolderEndPath = targetAssetFolder + "/" + Path.GetFileName(moveData.assetFolderStartPath); moveData.sourceFolderStartPath = path.Replace("Assets", sourceFolderRoot); moveData.sourceFolderEndPath = targetAssetFolder + "/" + Path.GetFileName(moveData.sourceFolderStartPath); var projectFolder = Application.dataPath.Replace("/Assets", ""); var sourceFullPath = projectFolder + "/" + moveData.sourceFolderStartPath; moveData.sourceExists = Directory.Exists(sourceFullPath); moves.Add(moveData); } GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Target asset folder:", GUILayout.Width(120)); if (GUILayout.Button(targetAssetFolder, EditorStyles.textField)) { var newFolder = EditorUtility.OpenFolderPanel("Select target folder", targetAssetFolder, ""); if (newFolder.Contains(Application.dataPath)) { targetAssetFolder = newFolder.Replace(Application.dataPath, "Assets"); } else { GameDebug.LogError("Target folder must be below the project Asset folder "); } } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Move")) { var result = EditorUtility.DisplayDialog("Move", "Are you sure you want to move", "Ok"); } var defaultColor = GUI.color; GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(100)); foreach (var move in moves) { GUILayout.Label("Asset folder:"); GUILayout.Label("Source folder:"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); foreach (var move in moves) { GUILayout.Label(move.assetFolderStartPath); GUI.color = move.sourceExists ? defaultColor : Color.red; GUILayout.Label(move.sourceFolderStartPath); GUI.color = defaultColor; } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(40)); foreach (var move in moves) { GUILayout.Label("=>"); GUILayout.Label("=>"); } GUILayout.EndVertical(); GUILayout.BeginVertical(); foreach (var move in moves) { GUILayout.Label(move.assetFolderEndPath); GUILayout.Label(move.sourceFolderEndPath); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
public LearnedMove(MoveData _move, int _level) { move = _move; level = _level; }
public bool CanMoveTo(MoveData newPositionData) { return(!Map.BlocksPath(new Vector2(newPositionData.X, newPositionData.Y))); }
void UseMove(string moveName) { MoveData moveData = PokemonData.GetMove(moveName); switch (moveData.effect) { case "noEffect": break; case "twoFiveEffect": break; case "payDayEffect": break; case "burnSideEffect1": break; case "freezeSideEffect": break; case "paralyzeSideEffect1": break; case "ohkoEffect": break; case "chargeEffect": break; case "attackUp2Effect": break; case "switchTeleportEffect": break; case "flyEffect": break; case "trappingEffect": break; case "flinchSideEffect2": break; case "doubleAttackEffect": break; case "jumpKickEffect": break; case "accuracyDown1Effect": break; case "paralyzeSideEffect2": break; case "recoilEffect": break; case "thrashEffect": break; case "defenseDown1Effect": break; case "poisonSideEffect1": break; case "twinNeedleEffect": break; case "flinchSideEffect1": break; case "attackDown1Effect": break; case "sleepEffect": break; case "confusionEffect": break; case "specialDamageEffect": break; case "disableEffect": break; case "defenseDownSideEffect": break; case "mistEffect": break; case "confusionSideEffect": break; case "speedDownSideEffect": break; case "attackDownSideEffect": break; case "hyperBeamEffect": break; case "drainHpEffect": break; case "leechSeedEffect": break; case "specialUp1Effect": break; case "poisonEffect": break; case "paralyzeEffect": break; case "speedDown1Effect": break; case "specialDownSideEffect": break; case "attackUp1Effect": break; case "speedUp2Effect": break; case "rageEffect": break; case "mimicEffect": break; case "defenseDown2Effect": break; case "evasionUp1Effect": break; case "healEffect": break; case "defenseUp1Effect": break; case "defenseUp2Effect": break; case "lightScreenEffect": break; case "hazeEffect": break; case "reflectEffect": break; case "focusEffect": break; case "bideEffect": break; case "metronomeEffect": break; case "mirrorMoveEffect": break; case "explodeEffect": break; case "poisonSideEffect2": break; case "burnSideEffect2": break; case "swiftEffect": break; case "specialUp2Effect": break; case "dreamEaterEffect": break; case "transformEffect": break; case "splashEffect": break; case "conversionEffect": break; case "superFangEffect": break; case "substituteEffect": break; } }
void OnGUI() { if (!PSMoveInput.IsConnected) { GUI.Label(new Rect(20, 45, 30, 35), "IP:"); ipAddress = GUI.TextField(new Rect(60, 45, 120, 25), ipAddress); GUI.Label(new Rect(190, 45, 30, 35), "port:"); port = GUI.TextField(new Rect(230, 45, 50, 25), port); if (GUI.Button(new Rect(300, 40, 100, 35), "Connect")) { PSMoveInput.Connect(ipAddress, int.Parse(port)); } } else { if (GUI.Button(new Rect(20, 40, 100, 35), "Disconnect")) { PSMoveInput.Disconnect(); Reset(); } GUI.Label(new Rect(10, 10, 150, 100), "PS Move count : " + PSMoveInput.MoveCount); GUI.Label(new Rect(140, 10, 150, 100), "PS Nav count : " + PSMoveInput.NavCount); //camera stream on/off if (GUI.Button(new Rect(5, 80, 130, 35), cameraStr)) { if (cameraStr == "Camera Switch On") { PSMoveInput.CameraFrameResume(); cameraStr = "Camera Switch Off"; } else { PSMoveInput.CameraFramePause(); cameraStr = "Camera Switch On"; } } //color and rumble for move number 0 if (PSMoveInput.MoveControllers[0].Connected) { //Set Color and Track GUI.Label(new Rect(300, 50, 200, 20), "R,G,B are floats that fall in 0 ~ 1"); GUI.Label(new Rect(260, 20, 20, 20), "R"); rStr = GUI.TextField(new Rect(280, 20, 60, 20), rStr); GUI.Label(new Rect(350, 20, 20, 20), "G"); gStr = GUI.TextField(new Rect(370, 20, 60, 20), gStr); GUI.Label(new Rect(440, 20, 20, 20), "B"); bStr = GUI.TextField(new Rect(460, 20, 60, 20), bStr); if (GUI.Button(new Rect(550, 30, 160, 35), "SetColorAndTrack")) { try { float r = float.Parse(rStr); float g = float.Parse(gStr); float b = float.Parse(bStr); PSMoveInput.MoveControllers[0].SetColorAndTrack(new Color(r, g, b)); } catch (Exception e) { Debug.Log("input problem: " + e.Message); } } //Rumble rumbleStr = GUI.TextField(new Rect(805, 20, 40, 20), rumbleStr); GUI.Label(new Rect(800, 50, 200, 20), "0 ~ 19"); if (GUI.Button(new Rect(870, 30, 100, 35), "Rumble")) { try { int rumbleValue = int.Parse(rumbleStr); PSMoveInput.MoveControllers[0].SetRumble(rumbleValue); } catch (Exception e) { Debug.Log("input problem: " + e.Message); } } } //move controller information for (int i = 0; i < PSMoveInput.MAX_MOVE_NUM; i++) { MoveController moveController = PSMoveInput.MoveControllers[i]; if (moveController.Connected) { MoveData moveData = moveController.Data; string display = "PS Move #" + i + "\nPosition:\t\t" + moveData.Position + "\nVelocity:\t\t" + moveData.Velocity + "\nAcceleration:\t\t" + moveData.Acceleration + "\nOrientation:\t\t" + moveData.Orientation + "\nAngular Velocity:\t\t" + moveData.AngularVelocity + "\nAngular Acceleration:\t\t" + moveData.AngularAcceleration + "\nHandle Position:\t\t" + moveData.HandlePosition + "\nHandle Velocity:\t\t" + moveData.HandleVelocity + "\nHandle Acceleration:\t\t" + moveData.HandleAcceleration + "\n" + "\nTrigger Value:\t\t" + moveData.ValueT + "\nButtons:\t\t" + moveData.Buttons + "\nSphere Color:\t\t" + moveData.SphereColor + "\nIs Tracking:\t\t" + moveData.IsTracking + "\nTracking Hue:\t\t" + moveData.TrackingHue; GUI.Label(new Rect(10 + 650 * (i / 2), 120 + 310 * (i % 2), 300, 400), display); } } for (int j = 0; j < PSMoveInput.MAX_NAV_NUM; j++) { NavController navController = PSMoveInput.NavControllers[j]; if (navController.Connected) { NavData navData = navController.Data; string navDisplay = "PS Nav #" + j + "\nAnalog :\t\t" + navData.ValueAnalog + "\nL2 Value:\t\t" + navData.ValueL2 + "\nButtons:\t\t" + navData.Buttons; GUI.Label(new Rect(400, 100 + 95 * j, 150, 95), navDisplay); } } } }
/// <summary> /// A daemon routine, as long as AllowNavigate is true and AStarPath is not null, navigate moving along /// the AStarPath automatically /// </summary> /// <returns></returns> public IEnumerator AStarNavigate() { while (true) { if (Halt == true || AllowNavigate == false || AStarPath == null || AStarPath.vectorPath == null || AStarPath.vectorPath.Length == 0) { yield return null; continue; } if (Vector3.Distance(transform.position, AStarPath.vectorPath[CurrentPathNodeIndex]) >= ReachCheckDistance) { Vector3 direction = (AStarPath.vectorPath[CurrentPathNodeIndex] - transform.position); float Speed = NavigationMoveData.MoveSpeed; if (NavigationMoveData.CanRotate) { if (NavigationMoveData.SmoothRotate) Util.MoveSmoothly(transform, direction.normalized * Speed, controller, NavigationMoveData.RotateAngularSpeed, NavigationMoveData.UseGravityWhenMoving); else Util.MoveTowards(transform, transform.position + direction, controller, true, false, Speed, 0, NavigationMoveData.UseGravityWhenMoving); } else { Util.MoveTowards(transform, direction, controller, Speed, NavigationMoveData.UseGravityWhenMoving); } if(NavigationMoveData.UseAnimation) { animation.CrossFade(NavigationMoveData.AnimationName); } } else //reach the current node { //move to next path point CurrentPathNodeIndex++; //reach the last node, reset navigation condition, and disable auto refresh pathing condition if (CurrentPathNodeIndex >= AStarPath.vectorPath.Length) { AStarPath = null; AllowNavigate = false; AutoRefreshPath = false; NaivgateToTarget = null; NavigationMoveData = null; } continue; } yield return null; } }
void Player_InfoReceived(object sender, ShogiCore.USI.USIInfoEventArgs e) { string infoDepth = ""; string infoSelDepth = ""; string infoTime = ""; string infoNodes = ""; string infoNPS = ""; string infoScore = ""; string infoCurrMove = ""; string infoHashFull = ""; string infoPVOrString = null; string pvLengthString = null; bool lowerBound = false, upperBound = false; foreach (USIInfo info in e.SubCommands) { switch (info.Name) { case "depth": infoDepth = info.Parameters.FirstOrDefault(); break; case "seldepth": infoSelDepth = info.Parameters.FirstOrDefault(); break; case "time": infoTime = info.Parameters.FirstOrDefault(); break; case "nodes": infoNodes = info.Parameters.FirstOrDefault(); break; case "nps": infoNPS = info.Parameters.FirstOrDefault(); break; case "currmove": infoCurrMove = info.Parameters.FirstOrDefault(); break; case "hashfull": infoHashFull = info.Parameters.FirstOrDefault(); break; case "score": if (player.LastScoreWasMate) { int mateCount = Math.Abs(player.LastScore) - USIPlayer.MateValue; string mateCountStr = mateCount == 0 ? "" : ":" + mateCount.ToString(); infoScore = (0 < player.LastScore ? "+Mate" : "-Mate") + mateCountStr; } else { infoScore = player.LastScoreString; } break; case "lowerbound": lowerBound = true; break; case "upperbound": upperBound = true; break; case "pv": { var pvList = info.Parameters; BoardData b = Board == null ? null : Board.ToBoardData(); List <string> itemList = new List <string>(); int pvLength = 0; foreach (var pv in pvList) { try { MoveData moveData = SFENNotationReader.ToMoveData(pv); if (b == null) { itemList.Add(moveData.ToString()); } else { itemList.Add(moveData.ToString(b)); b.Do(moveData); } pvLength++; } catch (NotationException) { itemList.Add(pv); } } infoPVOrString = string.Concat(itemList.ToArray()); pvLengthString = "PV長=" + pvLength; } break; case "string": infoPVOrString = string.Join(" ", info.Parameters); break; } } if (!string.IsNullOrEmpty(infoSelDepth)) { infoDepth += "/" + infoSelDepth; } long time, nodes, hashFull; if (long.TryParse(infoTime, out time)) { infoTime = time.ToString("#,##0"); } if (long.TryParse(infoNodes, out nodes)) { infoNodes = nodes.ToString("#,##0"); } if (long.TryParse(infoHashFull, out hashFull)) { infoHashFull = (hashFull / 10.0).ToString("0.0").PadLeft(5) + "%"; } if (lowerBound) { infoScore += "↑"; } if (upperBound) { infoScore += "↓"; } string toolTipText = pvLengthString; if (!string.IsNullOrEmpty(infoDepth)) { toolTipText = "深さ=" + infoDepth + " " + toolTipText; } try { FormUtility.SafeInvoke(this, () => { if (!string.IsNullOrEmpty(infoNPS)) { long nps; labelNPS.Text = long.TryParse(infoNPS, out nps) ? "NPS:" + nps.ToString("#,##0") : "NPS:" + infoNPS; } if (!string.IsNullOrEmpty(infoCurrMove)) { if (Board == null) { labelCurMove.Text = "探索手:" + SFENNotationReader.ToMoveData(infoCurrMove).ToString(); } else { labelCurMove.Text = "探索手:" + ShogiCore.Move.FromNotation(Board, SFENNotationReader.ToMoveData(infoCurrMove)).ToString(Board); } } if (!string.IsNullOrEmpty(infoHashFull)) { labelHashFull.Text = "ハッシュ使用率:" + infoHashFull; } if (!string.IsNullOrEmpty(infoPVOrString)) { AddListItem(infoTime, infoDepth, infoNodes, infoScore, infoPVOrString, pvLengthString); } double?meanDepth = stat.MeanDepth; double?meanNPS = stat.MeanNPS; if (meanDepth.HasValue) { labelMeanDepth.Text = "平均深さ:" + meanDepth.Value.ToString("#0.0"); } else { labelMeanDepth.Text = "平均深さ:-"; } if (meanNPS.HasValue) { labelMeanNPS.Text = "平均NPS:" + meanNPS.Value.ToString("#,##0"); } else { labelMeanNPS.Text = "平均NPS:-"; } }); } catch { // 無視 } }
public void TestCreateJoinAndStartGame() { // CluelessServerConnection is not designed for async, so async verifications are // being commented out CluelessServerConnection connect = CluelessServerConnection.getConnection( "localhost", 50351); // Host actions Assert.IsTrue(connect.registerAsPlayer("Harry Potter")); { // Success var lobbies = connect.Lobbies.GetLobbies(); Assert.IsNotNull(lobbies); var lobby = connect.Lobbies.CreateLobby(); Assert.IsNotNull(lobby); lobbies = connect.Lobbies.GetLobbies(); Assert.IsNotNull(lobbies); Assert.AreNotEqual(0, lobbies.Count); // Harry is host, he is already in game Assert.IsFalse(connect.Lobbies.JoinLobby(lobby)); } // Other player actions // Task<bool> ronWaitForGame = null; Assert.IsTrue(connect.registerAsPlayer("Ron Weasley")); { // Success var lobbies = connect.Lobbies.GetLobbies(); var lobby = lobbies[lobbies.Count - 1]; // Ron is not host, he can join Assert.IsTrue(connect.Lobbies.JoinLobby(lobby)); connect.registerToGame(lobby); // registerToGame makes it so 'lobby' isn't needed // as a parameter for further API calls // This function is a blocking call if game has not started. // The client should call this to wait for the game to begin. // There currently isn't a way to cancel a wait. Ryan can // implement that later if desired // if (!connect.Lobbies.WaitForGameStart()) // throw new Exception("Unsuccessful Wait for game start"); // Ron cannot start game because he is not the host Assert.IsFalse(connect.Lobbies.StartGame()); // ronWaitForGame = connect.Lobbies.WaitForGameStartAsync(); // Assert.IsFalse(ronWaitForGame.IsCompleted); } // Have a third person join // Task<bool> hermioneWaitForGame = null; Assert.IsTrue(connect.registerAsPlayer("Hermione")); { // Success var lobbies = connect.Lobbies.GetLobbies(); var lobby = lobbies[lobbies.Count - 1]; Assert.IsTrue(connect.Lobbies.JoinLobby(lobby)); connect.registerToGame(lobby); // hermioneWaitForGame = connect.Lobbies.WaitForGameStartAsync(); // Assert.IsFalse(hermioneWaitForGame.IsCompleted); } // Host can start game Assert.IsTrue(connect.registerAsPlayer("Harry Potter")); { Assert.IsTrue(connect.Lobbies.StartGame()); // Allow call to be sent to Hermione and Ron // Thread.Sleep(3100); // Assert.IsTrue(ronWaitForGame.IsCompleted); // response has come back // Assert.IsTrue(ronWaitForGame.Result); // game has started // Assert.IsTrue(hermioneWaitForGame.IsCompleted); // Assert.IsTrue(hermioneWaitForGame.Result); } // other players 'WaitForGameStart()' will now return true Assert.IsTrue(connect.registerAsPlayer("Ron Weasley")); { Assert.IsTrue(connect.Lobbies.WaitForGameStart()); } Assert.IsTrue(connect.registerAsPlayer("Hermione")); { Assert.IsTrue(connect.Lobbies.WaitForGameStart()); } // Play the game now // Get cards String[] players = { "Harry Potter", "Ron Weasley", "Hermione" }; List <Card> previousPlayersCards = null; Command lastSeenCommand = null; foreach (var playerName in players) { // verify that each player has a hand of cards Assert.IsTrue(connect.registerAsPlayer(playerName)); if (!playerName.Equals("Harry Potter")) // Harry will get message 'Take Turn' { // WaitForCommand should return immediately and not wait here Command command = connect.Gameplay.WaitForCommand(); Assert.AreEqual(CommandType.GameStart, command.command); lastSeenCommand = command; // remove last seen command so that hermione won't block connect.Gameplay.TestOnlySetLastSeenCommand(null); } var cards = connect.Gameplay.GetPlayerHand(); Assert.IsNotNull(cards); Assert.AreNotEqual(0, cards.Count); //// Make sure each hand is unique Assert.AreNotEqual(previousPlayersCards, cards); previousPlayersCards = cards; } // The async code doesn't work with a ClientController task that is // intended for a single process // Task<Command> ronWaitForCommand, hermioneWaitForCommand; // take turn Assert.IsTrue(connect.registerAsPlayer("Harry Potter")); { // Get game state to verify correct information Game game = connect.Gameplay.GetState(); Assert.IsNotNull(game); Command command = connect.Gameplay.WaitForCommand(); Assert.AreEqual(CommandType.TakeTurn, command.command); { // Restore Ron & Hermione's last seen command, since they've seen it, // the request for a command should block connect.Gameplay.TestOnlySetLastSeenCommand(lastSeenCommand); /* * Assert.IsTrue(connect.registerAsPlayer("Ron Weasley")); * ronWaitForCommand = connect.Gameplay.WaitForCommandAsync(); * * Assert.IsTrue(connect.registerAsPlayer("Hermione")); * hermioneWaitForCommand = connect.Gameplay.WaitForCommandAsync(); * * Assert.IsFalse(ronWaitForCommand.IsCompleted); * Assert.IsFalse(hermioneWaitForCommand.IsCompleted); */ } // Harry's starting spot is Scarlet's: new Location(0,3,"Hallway") var expectedMoveData = new MoveData { playerName = "Harry Potter", location = new Location(0, 2, "Hallway") }; Assert.IsTrue(connect.registerAsPlayer(expectedMoveData.playerName)); bool successful = connect.Gameplay.MovePlayerTo(expectedMoveData.location); Assert.IsTrue(successful); // Make sure that Ron & Hermione received message { /* * Thread.Sleep(3100); * Assert.IsTrue(ronWaitForCommand.IsCompleted); * Assert.IsTrue(hermioneWaitForCommand.IsCompleted); * * Command cmd = ronWaitForCommand.Result; */ connect.Gameplay.TestOnlySetLastSeenCommand(lastSeenCommand); Assert.IsTrue(connect.registerAsPlayer("Ron Weasley")); Command cmd = connect.Gameplay.WaitForCommand(); connect.Gameplay.TestOnlySetLastSeenCommand(lastSeenCommand); Assert.IsTrue(connect.registerAsPlayer("Hermione")); Command cmd2 = connect.Gameplay.WaitForCommand(); // Ron & Hermione received the same command Assert.AreEqual(cmd, cmd2); // This is the expected command data Assert.AreEqual(CommandType.MovePlayer, cmd.command); Assert.IsNotNull(cmd.data.moveData); Assert.AreEqual(expectedMoveData, cmd.data.moveData); lastSeenCommand = cmd; } Assert.IsTrue(connect.registerAsPlayer("Harry Potter")); // This blocks // DisproveData result = connect.Gameplay.MakeSuggestion(new Accusation(Room.Ballroom, Suspect.Mustard, Weapon.Pipe)); // if null, no one could disprove // Otherwise, result.card is the proof, and result.playerName is the owner of 'card' // This is called by the 'other' player, not by Harry // successful = connect.Gameplay.DisproveSuggestion(new Card(Weapon.Pipe)); Accusation accusation = new Accusation(Room.Ballroom, Suspect.Mustard, Weapon.Pipe); AccusationData data = connect.Gameplay.MakeAccusation(accusation); Assert.IsNotNull(data); Assert.AreEqual(accusation, data.accusation); Assert.IsFalse(data.accusationCorrect); successful = connect.Gameplay.EndTurn(); Assert.IsTrue(successful); Accusation solution = connect.Gameplay.GetSolution(); Assert.IsNull(solution); // game is not finished. Solution not available until then // it is now Ron's turn Assert.IsTrue(connect.registerAsPlayer("Ron Weasley")); Command finalCmd = connect.Gameplay.WaitForCommand(); Assert.IsNotNull(finalCmd); Assert.AreEqual(CommandType.TakeTurn, finalCmd.command); successful = connect.Gameplay.EndTurn(); Assert.IsTrue(successful); // Hermione's turn Assert.IsTrue(connect.registerAsPlayer("Hermione")); finalCmd = connect.Gameplay.WaitForCommand(); Assert.IsNotNull(finalCmd); Assert.AreEqual(CommandType.TakeTurn, finalCmd.command); successful = connect.Gameplay.EndTurn(); Assert.IsTrue(successful); // Harry's turn again Assert.IsTrue(connect.registerAsPlayer("Harry Potter")); finalCmd = connect.Gameplay.WaitForCommand(); Assert.IsNotNull(finalCmd); Assert.AreEqual(CommandType.TakeTurn, finalCmd.command); } }
public MoveData GetClone() { MoveData clone = new MoveData(); base.CloneBasic(clone as UnitAnimationData); clone.MoveSpeed = this.MoveSpeed; clone.CanRotate = this.CanRotate; clone.SmoothRotate = this.SmoothRotate; clone.RotateAngularSpeed = this.RotateAngularSpeed; clone.UseGravityWhenMoving = this.UseGravityWhenMoving; return clone; }
// Update is called once per frame void Update() { if (PSMoveInput.IsConnected == true) { controller = PSMoveInput.MoveControllers[index]; moveData = controller.Data; if (controller.Connected == true && moveData != null) { string buttonsSt = ""+moveData.Buttons; bool isTriggerDown = moveData.Buttons == MoveButton.T || (psMoveWraper.gyroEnabled && psMoveWraper.gyroAnalogScale && moveData.ValueT >= psMoveWraper.gyroAnalogMin); if(moveData.Buttons == MoveButton.Start && isCalibrationEnabled == true){ isCalibrationEnabled = false; LeanTween.delayedCall(1f,()=>{ isCalibrationEnabled = true; }); psMoveWraper.CalibratePlayer(index); } else if ((buttonsSt == "Square, T" || buttonsSt == "T, Square" || moveData.Buttons == MoveButton.Square) && curShape != Shape.SQUARE && snapState == SnapState.UnsnappedAndSnappable) { changeShape(Shape.SQUARE); } else if ((buttonsSt == "Triangle, T" || buttonsSt == "T, Triangle" || moveData.Buttons == MoveButton.Triangle) && curShape != Shape.TRIANGLE && snapState == SnapState.UnsnappedAndSnappable) { changeShape(Shape.TRIANGLE); } else if ((buttonsSt == "Circle, T" || buttonsSt == "T, Circle" || moveData.Buttons == MoveButton.Circle) && curShape != Shape.CIRCLE && snapState == SnapState.UnsnappedAndSnappable) { changeShape(Shape.CIRCLE); } else if ((buttonsSt == "Cross, T" || buttonsSt == "T, Cross" || moveData.Buttons == MoveButton.Cross) && curShape != Shape.CROSS && snapState == SnapState.UnsnappedAndSnappable) { changeShape(Shape.CROSS); } else if (isTriggerDown) { if(!playedTriggerSound) { AudioManager.Main.PlayNewSound("Puzzle_lock"); playedTriggerSound = true; } // Update border particles if (!GetComponent<ParticleManager> ().IsPlaying () && this.snapState != SnapState.SnappedAndUnsnappable) { GetComponent<ParticleManager> ().Play (); } else if (GetComponent<ParticleManager> ().IsPlaying () && this.snapState == SnapState.SnappedAndUnsnappable) { GetComponent<ParticleManager> ().Stop (); } if (!psMoveWraper.gyroEnabled) { Vector3 curScale = gameObject.transform.localScale; if(prevZPosition == 0f){ prevZPosition = (float) Math.Round((double)moveData.Position.z, 1) ; isRaisingScale = 0; } float curZPosition = (float) Math.Round((double)moveData.Position.z, 1) ; if(curZPosition > prevZPosition){ isRaisingScale = 1; } else if(curZPosition < prevZPosition){ isRaisingScale = -1; } else{ isRaisingScale = 0; } prevZPosition = (float) Math.Round((double) moveData.Position.z, 1); if(isRaisingScale == 1){ gameObject.transform.localScale = new Vector3(minScale,minScale,minScale) * Mathf.Clamp(curScale.x + (Time.deltaTime*scaleSpeed),minScale,maxScale); } else if(isRaisingScale == -1){ gameObject.transform.localScale = new Vector3(minScale,minScale,minScale) * Mathf.Clamp(curScale.x - (Time.deltaTime*scaleSpeed),minScale,maxScale); } else{ isRaisingScale = 0; } } } else{ isRaisingScale = 0; playedTriggerSound = false; if(snapState == SnapState.SnappedAndUnsnappable) { if(moveData.ValueT == 0 && psMoveWraper.isHandleActive[index] == false){ snapState = SnapState.UnsnappedAndUnsnappable; enablePlayer(); } } } // Update border particles if (!isTriggerDown && GetComponent<ParticleManager>().IsPlaying()) GetComponent<ParticleManager>().Stop(); } } if( ((Input.GetKey(KeyCode.Keypad1) == true || Input.GetKey(KeyCode.Alpha1) == true) && index == 0) || ((Input.GetKey(KeyCode.Keypad2) == true || Input.GetKey(KeyCode.Alpha2) == true) && index == 1) || ((Input.GetKey(KeyCode.Keypad3) == true || Input.GetKey(KeyCode.Alpha3) == true) && index == 2)){ checkKeyboardControls(); } }
/// <summary> /// Helper functions - navigating AI to transform. /// The function returns when distance to target transform lesser than BreakDistance, /// or Navigation time exceeds given BreakTime. /// </summary> public virtual IEnumerator NavigateToTransform(Transform TargetTransform, MoveData moveData, float BreakDistance, float BreakTime) { float _navigationStartTime = Time.time; float _lastNavigationTime = Time.time; StartNavigation(CurrentTarget, true, moveData); while (TargetTransform != null && (Vector3.Distance(transform.position,TargetTransform.position) > BreakDistance && (Time.time - _navigationStartTime) <= BreakTime) ) { //we need to refresh the navigation path in a fixed time if ((Time.time - _lastNavigationTime) >= moveData.RedirectTargetInterval) { StartNavigation(TargetTransform, true, moveData); _lastNavigationTime = Time.time; } yield return null; } StopNavigation(); }
// Update is called once per frame void FixedUpdate() { if (PSMoveInput.IsConnected) { MoveData moveData = new MoveData(); if (controllerNumber != -1 && PSMoveInput.MoveControllers [controllerNumber].Connected) { moveData = PSMoveInput.MoveControllers [controllerNumber].Data; } else { bool found = false; for (int i = 0; i < PSMoveInput.MoveControllers.Length; i++) { if (PSMoveInput.MoveControllers[i].Connected) { moveData = PSMoveInput.MoveControllers[i].Data; controllerNumber = i; found = true; break; } } if (!found) { return; } } handlePos = moveData.HandlePosition * handlePositionSensitivity + handlePositionOffset; handle.transform.localPosition = new Vector3 (handlePos.x, handlePos.y, -handlePos.z); handle.transform.localRotation = Quaternion.Euler (-moveData.Orientation); if (moveData.ValueT > 0) { //If tractor beam is not lit up, light it up if (!beamOn) { Debug.Log ("Beam on!"); //beam.SetActive(true); beamOn = true; //add sound effect here (modified by Yang) handle.GetComponent<TrackbeamSound>().PlaySound(); } //If speed is above speed threshold if (moveData.Velocity.magnitude >= speedThreshold && activePlatform != null && activePlatform.gameObject.layer == Utility.ToLayerNumber( gridSystem.movablePfLayer)) { float xVel = moveData.Velocity.x; Vector3 oVec = activePlatform.gameObject.transform.position; Vector3 pVec = robot.transform.position; Int2 pIdx = gridSystem.ComputeIdx (new Vector2 (pVec.x, pVec.z)); Debug.Log (pVec); Debug.Log (oVec); int dX = Mathf.RoundToInt (pVec.x) - Mathf.RoundToInt (oVec.x); int dZ = Mathf.RoundToInt (pVec.z) - Mathf.RoundToInt (oVec.z); if (dX == 0) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisZ, pIdx); } else if (dZ == 0) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisX, pIdx); } else { if (dX < 0) { if (dZ > 0) { if (xVel > angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisX, pIdx); } else if (xVel < -angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisZ, pIdx); } } else { if (xVel > angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisZ, pIdx); } else if (xVel < -angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisX, pIdx); } } } else { if (dZ > 0) { if (xVel > angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisZ, pIdx); } else if (xVel > -angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisX, pIdx); } } else { if (xVel > angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisX, pIdx); } else if (xVel > -angledSpeedThreshold) { activePlatform.group.StartMoveGroup (PlatformMoveType.AxisZ, pIdx); } } } } } } else { if (beamOn) { Debug.Log ("Beam off!"); beamOn = false; if (activePlatform != null) { if (activePlatform.group != null) { activePlatform.group.Deactivate(); } activePlatform = null; } } } } }
void Start() { _attack = GameObject.Find("Cup"); _pourCoffePos = GameObject.Find("PourCoffe"); _move = GetComponent<MoveData>(); _canAttack = StartWithCup; _attack.SetActive(StartWithCup); }
protected override void SpecificResolve(MoveData move) { Debug.Assert(move.Target != move.Player); // Learn the target's hand move.Player.LearnHand(move.Target); }
public abstract MoveData.DualUtility EstimateMoveUtility(MoveData move, CardController otherCard, AIGenericPerceptor perceptorData);
/// <summary> /// Fallback in the specified time. /// target is optional, if target is null, fallback direction is back direction in local space. /// </summary> public IEnumerator Fallback(float timelength, MoveData movedata, Transform target) { float time = Time.time; animation.CrossFade(movedata.AnimationName); while((Time.time - time ) <= timelength) { if(target != null) { Util.RotateToward(transform,target.position, movedata.SmoothRotate, movedata.RotateAngularSpeed); } if(movedata.UseGravityWhenMoving) { controller.SimpleMove(transform.TransformDirection(Vector3.back) * movedata.MoveSpeed); } else { controller.Move(transform.TransformDirection(Vector3.back) * movedata.MoveSpeed * Time.deltaTime); } yield return null; } }
void Start() { _move = GetComponent <MoveData>(); }
private void UpdateMoveData(MoveData moveData) { moveDataSet.Add(moveData); }