/// <summary> /// Queue an animation to show a card being exhausted from the player's hand. /// </summary> public void AnimateExhaust(ICard card, Chase newState) { // Remove the first matching card from the player's hand. UICardView uiCard = FindCard(this.Hand.transform, card); if (uiCard != null) { uiCard.CardRemoved = true; AddAnimationToQueue(new QueuedAnimation(null, null, () => { Destroy(uiCard.gameObject); }, null)); return; } uiCard = FindCard(this.Route.transform, card); if (uiCard != null) { uiCard.CardRemoved = true; AddAnimationToQueue(new QueuedAnimation(null, null, () => { Destroy(uiCard.gameObject); }, null)); return; } uiCard = FindCard(this.Pursuit.transform, card); if (uiCard != null) { uiCard.CardRemoved = true; AddAnimationToQueue(new QueuedAnimation(null, null, () => { Destroy(uiCard.gameObject); }, null)); return; } }
public BTEnemy(Agent ownerBrain) : base(ownerBrain) { rootSelector = new Selector(); enemyCheck = new Sequence(); patrolSequence = new Sequence(); suspiciousSequence = new Sequence(); ChaseSequence = new Sequence(); DistractionSequence = new Sequence(); parallelDetection = new Parallel(); checkInverter = new Inverter(); turnToPoint = new TurnToPoint(GetOwner()); patrol = new Patrol(GetOwner()); wait = new Wait(GetOwner()); detection = new Detection(GetOwner()); distraction = new Distraction(GetOwner()); suspicious = new Suspicious(GetOwner()); suspiciousAlert = new SuspiciousAlert(GetOwner()); moveToLKP = new MoveToLKP(GetOwner()); seen = new Seen(GetOwner()); chase = new Chase(GetOwner()); //Root -> Patrol and Check rootSelector.AddChild(parallelDetection); parallelDetection.AddChild(checkInverter); //A parallel to check for the player checkInverter.AddChild(detection); //Patrol alongside checking for the player parallelDetection.AddChild(patrolSequence); patrolSequence.AddChild(patrol); patrolSequence.AddChild(wait); patrolSequence.AddChild(turnToPoint); //Root -> Adding sequences rootSelector.AddChild(suspiciousSequence); rootSelector.AddChild(ChaseSequence); rootSelector.AddChild(DistractionSequence); //Distraction State DistractionSequence.AddChild(distraction); DistractionSequence.AddChild(wait); //Suspicious state suspiciousSequence.AddChild(suspicious); suspiciousSequence.AddChild(suspiciousAlert); suspiciousSequence.AddChild(moveToLKP); suspiciousSequence.AddChild(wait); //Chase state ChaseSequence.AddChild(seen); ChaseSequence.AddChild(chase); ChaseSequence.AddChild(wait); }
/// <summary> /// Queue an animation to change the player's current control. /// </summary> public void AnimateControlChange(int delta, Chase newState) { AddAnimationToQueue(new QueuedAnimation(ControlAnimator, delta > 0 ? "StatUp" : "StatDown", () => { this.ControlLabel.text = newState.Control.ToString("N0"); this.ControlLabelDelta.text = delta.ToString("N0"); }, null)); }
void Start() { _chase = GetComponent<Chase>(); _citizen = GetComponent<Citizen>(); _player = GetComponent<Player>(); _clickToMoveTo = GetComponent<ClickToMoveTo>(); }
public override Chase Play( Chase currentState, List <ICard> targetCards, UIManager uiManager ) { int cardsShuffled = currentState.PlayerDiscard.Count; ChaseMutator mutator = new ChaseMutator(currentState, uiManager, $"playing {this.Name}") .AddControl(-this.ControlCost) .ActivateCard(this); if (currentState.PlayerExhaust.Count > 0) { mutator.ResurrectFromExhaustToHand(currentState.PlayerExhaust.Last()); } foreach (IPlayerCard repairedDamage in targetCards) { if (repairedDamage != null) { mutator.ExhaustFromHand(repairedDamage); } } return(mutator .DiscardFromHand(this) .Done()); }
public override Chase Play( Chase currentState, List <ICard> targetCards, UIManager uiManager ) { ChaseMutator muta = new ChaseMutator(currentState, uiManager, $"playing {this.Name}") .AddControl(-this.ControlCost) .ActivateCard(this) .AddPlayerSpeed(currentState.MaxPlayerSpeed - currentState.PlayerSpeed) .AddLead(LeadIncrease) .AddDamageToTopOfDeck(DamageTaken); foreach (IRouteCard targetCard in targetCards) { if (targetCard != null) { muta.DiscardFromRoute(targetCard); } } return(muta .DiscardFromHand(this) .Done()); }
public override Chase Play(Chase currentState, UIManager uiManager) { return(new ChaseMutator(currentState, uiManager, $"playing {this.Name}") .ActivateCard(this) .AddLead(-LeadDecrease) .Done()); }
/// <summary> /// Queue an animation to change the player's max speed. /// </summary> public void AnimatePlayerMaxSpeedChange(int delta, Chase newState) { //AddAnimationToQueue(new QueuedAnimation(PlayerSpeedAnimator, delta > 0 ? "StatUp" : "StatDown", () => { // this.PlayerSpeedLabel.text = newState.PlayerSpeed.ToString("N0"); // this.PlayerSpeedLabelDelta.text = delta.ToString("N0"); //}, null)); }
/// <summary> /// 状态机初始化 /// </summary> private void ConstructFSM() { //针对每一个行为进行初始化, 针对于每个行为进行状态到行为转变的添加 //巡逻 Patrol patrol = new Patrol(this); patrol.AddTransition(Transition.SawPlayer, FSMActionID.Chasing); patrol.AddTransition(Transition.NoHealth, FSMActionID.Dead); //追逐 Chase chase = new Chase(this); chase.AddTransition(Transition.ReachPalyer, FSMActionID.Attacking); chase.AddTransition(Transition.LostPlayer, FSMActionID.Patroling); chase.AddTransition(Transition.NoHealth, FSMActionID.Dead); //攻击 Attack attack = new Attack(this); attack.AddTransition(Transition.SawPlayer, FSMActionID.Chasing); attack.AddTransition(Transition.LostPlayer, FSMActionID.Patroling); attack.AddTransition(Transition.NoHealth, FSMActionID.Dead); //死亡 Dead dead = new Dead(this); dead.AddTransition(Transition.NoHealth, FSMActionID.Dead); //把状态列表进行初始化 AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); }
private void Awake() { attackList = GetComponent <AttackList>(); patrol = GetComponent <Patrol>(); hold = GetComponent <Hold>(); chase = GetComponent <Chase>(); }
public override Chase Play(Chase currentState, UIManager uiManager) { return(new ChaseMutator(currentState, uiManager, $"playing {this.Name}") .ActivateCard(this) .AddDamageToTopOfDeck(Damage) .Done()); }
public override void Update() { Debug.Log("Patrolling"); //if distance left is greater than 1 if (agent.remainingDistance < 1) { //Decrement if (currentIndex >= GameEnvironment.Singelton.CheckPoints.Count - 1) { currentIndex = 0; } else { currentIndex++; } //move to new position agent .SetDestination(GameEnvironment .Singelton .CheckPoints[currentIndex] .transform .position); } //chase bee if possible if (CanSeeBee()) { nextState = new Chase(npc, agent, bee); stage = EVENT.EXIT; } }
private void Awake() { if (gameObject.activeSelf == true) { idle = new Idle(this); rest = new Rest(this); eat = new Eat(this); wander = new Wander(this); chase = new Chase(this); flee = new Flee(this); attack = new Attack(this); dead = new Dead(this); navAgent = GetComponentInParent <NavMeshAgent>(); tracker = GameObject.FindGameObjectWithTag("Tracker").GetComponent <Tracking>(); damageOutput = gameObject.GetComponentsInChildren <Damage>(); if (useAnimator == true) { anim = GetComponent <Animator>(); } if (dynamicWandering == false) { spawnpoint = transform.position; } } }
public void Start() { chaser = GetComponent <Chase> (); naver = GetComponent <enemynavmesh> (); attacking = GetComponent <IsBeingAttacked> (); enemies = GameObject.FindGameObjectsWithTag("enemy"); }
public async Task <Chase> UpdateChase(Chase chase) { var result = await chaseContext.Chases .FirstOrDefaultAsync(c => c.Id == chase.Id); if (result != null) { result.Name = chase.Name; result.Attribute1 = chase.Attribute1; result.Attribute2 = chase.Attribute2; result.Jutsu1 = chase.Jutsu1; result.Jutsu2 = chase.Jutsu2; result.Chasing = chase.Chasing; result.Causing = chase.Causing; result.Effects = chase.Effects; result.Description = chase.Description; result.ImagePath = chase.ImagePath; result.Hits = chase.Hits; result.Repeat = chase.Repeat; await chaseContext.SaveChangesAsync(); return(result); } return(null); }
public override Chase Play( Chase currentState, List <ICard> targetCards, UIManager uiManager ) { int speedIncrease = SpeedIncrease; int leadIncrease = LeadIncrease; if (currentState.PlayerSpeed != 0) { speedIncrease = 0; leadIncrease = 0; } ChaseMutator muta = new ChaseMutator(currentState, uiManager, $"playing {this.Name}") .AddControl(-this.ControlCost) .ActivateCard(this) .AddPlayerSpeed(speedIncrease) .AddLead(leadIncrease) .DiscardFromHand(this); foreach (IRouteCard targetCard in targetCards) { if (targetCard != null) { muta.DiscardFromRoute(targetCard); } } return(muta.Done()); }
public static bool beginCollisionWithKoopaTroopa(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; arbiter.GetShapes(out shape1, out shape2); KoopaTroopa koopa1 = shape1.GetComponent <KoopaTroopa>(); KoopaTroopa koopa2 = shape2.GetComponent <KoopaTroopa>(); bool hidden1 = koopa1._hide.isHidden(); bool hidden2 = koopa2._hide.isHidden(); bool bouncing1 = koopa1.bounce.isBouncing(); bool bouncing2 = koopa2.bounce.isBouncing(); // avoid koopa1 pushes hidden koopa2 Chase chase = shape1.GetComponent <Chase>(); if (chase != null && chase.isChasing()) { chase.stopChasing(); chase.enableOperateWhenOutOfSensor(); } // avoid koopa2 pushes hidden koopa1 chase = shape2.GetComponent <Chase>(); if (chase != null && chase.isChasing()) { chase.stopChasing(); chase.enableOperateWhenOutOfSensor(); } // is koopa above the other koopa? if (GameObjectTools.isGrounded(arbiter)) { if (!hidden1) { koopa1.jump.forceJump(koopa1.jumpSpeed); } else { koopa2.jump.forceJump(koopa1.jumpSpeed); } // NOTE: I assume here the isGrounded() works as expected return(false); // avoid the collision to continue since this frame } // kills koopa 2 else if (bouncing1 && !hidden2 && !bouncing2) { //koopa2.die(); koopa2.hide(); } // kills koopa 1 else if (bouncing2 && !hidden1 && !bouncing1) { //koopa1.die(); koopa1.hide(); } // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next frame. return(true); }
protected override void BrainInitialisation() { hp = configScriptable.bossHp; damage = configScriptable.bossDamage; speed = configScriptable.bossSpeed; bulletSpeed = configScriptable.bossBulletSpeed; damageDealed = false; brain = new Brain(true); Chase chase = new Chase(2f, transform, AI.GetPlayer(), speed * 2); RandomMove randomMove = new RandomMove(1f, transform, speed); ShootAtPosition shoot = new ShootAtPosition(.2f, transform, AI.GetPlayer(), false, bulletSpeed, damage); MultiShot multiShoot = new MultiShot(.2f, transform, AI.GetPlayer(), damage, bulletSpeed); AIWait aIWait = new AIWait(1f); brain.AddAIMechanic(chase); brain.AddAIMechanic(aIWait); brain.AddAIMechanic(multiShoot); brain.AddAIMechanic(aIWait); brain.AddAIMechanic(shoot); brain.AddAIMechanic(shoot); brain.AddAIMechanic(shoot); brain.AddAIMechanic(aIWait); brain.AddAIMechanic(randomMove); brain.ChooseState(); coroutine = Wait(brain.GetCooldown()); StartCoroutine(coroutine); }
/// <summary> /// Queue an animation to change the current pursuit speed. /// </summary> public void AnimatePursuitSpeedChange(int delta, Chase newState) { AddAnimationToQueue(new QueuedAnimation(PursuitSpeedAnimator, delta > 0 ? "StatUp" : "StatDown", () => { this.PursuitSpeedLabel.text = newState.PursuitSpeed.ToString("N0"); this.PursuitSpeedLabelDelta.text = delta.ToString("N0"); }, null)); }
// Start is called before the first frame update void Start() { Sequence root = new Sequence(bb); Selector targetSel = new Selector(bb); Help help = new Help(bb); ViewMark mark = new ViewMark(bb); NoDanger noDanger = new NoDanger(bb); Sequence actionSeq = new Sequence(bb); Selector ramSel = new Selector(bb); Sequence ramSeq = new Sequence(bb); LineOfSight los = new LineOfSight(bb); Boost boost = new Boost(bb); NormalizeBoost norm = new NormalizeBoost(bb); Chase chase = new Chase(bb); ramSeq.AddTask(los); ramSeq.AddTask(boost); ramSel.AddTask(ramSeq); ramSel.AddTask(norm); actionSeq.AddTask(ramSel); actionSeq.AddTask(chase); targetSel.AddTask(help); targetSel.AddTask(mark); root.AddTask(targetSel); root.AddTask(noDanger); root.AddTask(actionSeq); this.bt = root; }
public void Restart() { // Init BB m_Blackboard = new Blackboard(); m_Blackboard.Trans = transform; m_Blackboard.Player = GameObject.FindGameObjectWithTag("Player").transform; m_Blackboard.Destination = transform.position + new Vector3(10, 0, 5); m_Bt = new BehaviorTree(); m_Bt.m_Blackboard = m_Blackboard; // Init tree Repeat repeat = new Repeat(ref m_Bt, -1); Sequence randomMove = new Sequence(ref m_Bt); PickRandomTarget pickTarget = new PickRandomTarget(); MoveToPoint moveBehavior = new MoveToPoint(); randomMove.m_Children.Add(moveBehavior); randomMove.m_Children.Add(pickTarget); // Try out Chase behavior m_Chase = new Chase(moveBehavior, m_Bt); m_Flee = new Flee(moveBehavior, m_Bt); repeat.m_Child = randomMove; m_Bt.Start(repeat, this.SequenceComplete); }
// Update is called once per frame void Update() { // update distance between player and enemy _playerEnemyDistance = _playerTransform.position.x - _transform.position.x; // update edge detection Vector2 detectOffset; detectOffset.x = edgeSafeDistance * _transform.localScale.x; detectOffset.y = 0; _reachEdge = checkGrounded(detectOffset) ? 0 : (_transform.localScale.x > 0 ? 1 : -1); // update state if (!_currentState.checkValid(this)) { if (_isChasing) { _currentState = new Patrol(); } else { _currentState = new Chase(); } _isChasing = !_isChasing; } if (_isMovable) { _currentState.Execute(this); } }
public void FindPlayer() { //get player position playerPos = player.position; //start chasing chaseState = Chase.Chasing; }
// Update is called once per fram void Update() { if (target == null) { target = UnityStandardAssets.Characters.FirstPerson.FirstPersonController.Instance.gameObject.transform; } if (this.transform.position.y <= Maxy) { if (Rose == 0) { { this.transform.position += new Vector3(0, Risespeed, 0); if (this.transform.position.y >= Maxy) { Rose = 1; } } } } distance = (this.transform.position - target.position).magnitude; if (Rose == 1) { Chase script = GetComponent <Chase>(); script.enabled = true; } }
public static bool beginCollisionWithKoopaTroopa(ChipmunkArbiter arbiter) { ChipmunkShape shape1, shape2; arbiter.GetShapes(out shape1, out shape2); KoopaTroopa koopa1 = shape1.getOwnComponent <KoopaTroopa>(); KoopaTroopa koopa2 = shape2.getOwnComponent <KoopaTroopa>(); bool hidden1 = koopa1._hide.isHidden(); bool hidden2 = koopa2._hide.isHidden(); bool bouncing1 = koopa1.bounce.isBouncing(); bool bouncing2 = koopa2.bounce.isBouncing(); // avoid koopa1 pushes hidden koopa2 Chase chase1 = shape1.GetComponent <Chase>(); if (chase1 != null && chase1.isChasing()) { chase1.stop(); chase1.enableOperateWhenOutOfSensor(); } // avoid koopa2 pushes hidden koopa1 Chase chase2 = shape2.GetComponent <Chase>(); if (chase2 != null && chase2.isChasing()) { chase2.stop(); chase2.enableOperateWhenOutOfSensor(); } // is koopa1 above the koopa2? if (GameObjectTools.isGrounded(arbiter)) { if (!hidden1 && koopa1.jump.isJumping()) { koopa1.jump.forceJump(koopa1.jumpSpeed); } else if (hidden1 && koopa2.jump.isJumping()) { koopa2.jump.forceJump(koopa1.jumpSpeed); } return(false); // avoid the collision since this frame } // hide koopa 2 else if (bouncing1 && !hidden2 && !bouncing2) { koopa2.hide(); } // hide koopa 1 else if (bouncing2 && !hidden1 && !bouncing1) { //koopa1.die(); koopa1.hide(); } // Returning false from a begin callback means to ignore the collision response for these two colliding shapes // until they separate. Also for current frame. Ignore() does the same but next fixed step. return(true); }
public override IProvidesCardParameters GetParameterProvider(Chase chaseState) { // Capacious Toolbox needs to target a card in the player's exhaust. return(new CardParameterProvider <IPlayerCard>( chaseState.PlayerExhaust, NumCardsResurrected )); }
float timer; // Timer for counting up to the next attack. void Awake() { // Setting up the references. player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealthU>(); enemyHealth = GetComponent <Chase>(); anim = GetComponent <Animator>(); }
public override IProvidesCardParameters GetParameterProvider(Chase chaseState) { // Power on Through can target any route card. return(new CardParameterProvider <IRouteCard>( chaseState.CurrentRoute, RouteCardsDiscarded )); }
public async Task <Chase> AddChase(Chase chase) { var result = await chaseContext.Chases.AddAsync(chase); await chaseContext.SaveChangesAsync(); return(result.Entity); }
public override Chase Play(Chase currentState, UIManager uiManager) { return(new ChaseMutator(currentState, uiManager, $"playing {this.Name}") .ActivateCard(this) .AddPlayerSpeed(-SpeedDecrease) .DiscardFromRoute(this) .Done()); }
public override IProvidesCardParameters GetParameterProvider(Chase chaseState) { // Capacious Toolbox is a repair, so needs to target a Damage card in the player's hand. return(new CardParameterProvider <IPlayerCard>( chaseState.Hand .Where(card => card.CardType == PlayerCardType.Damage) .ToList() )); }
public override IProvidesCardParameters GetParameterProvider(Chase chaseState) { // J-Turn is a stunt, so it requires a Maneuver card as a parameter. return(new CardParameterProvider <IRouteCard>( chaseState.CurrentRoute .Where(card => card.CardType == RouteCardType.Maneuver) .ToList() )); }
public void Start() { //get the behaviours and set their data Walking walkingAI = _animator.GetBehaviour<Walking>(); walkingAI.commonParameters = commonParameters; walkingAI.parameters = walkingParameters; GoAway runningAway = _animator.GetBehaviour<GoAway>(); runningAway.commonParameters = commonParameters; runningAway.parameters = goAwayParameters; DetectPlayer detectedAI = _animator.GetBehaviour<DetectPlayer>(); detectedAI.parameters = detectParameters; detectedAI.commonParameters = commonParameters; Iddle iddle = _animator.GetBehaviour<Iddle>(); iddle.parameters = iddleParameters; iddle.commonParameters = commonParameters; _chaseAI = _animator.GetBehaviour<Chase>(); _chaseAI.commonParameters = commonParameters; _chaseAI.parameters = chaseParameters; Attack attackAI = _animator.GetBehaviour<Attack>(); attackAI.commonParameters = commonParameters; attackAI.parameters = attackParameters; actualState = GetAnimationState(_animator.GetCurrentAnimatorStateInfo(0)); }