protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( // If we've arrived at the destination, we're done... #region DefendType Unit new Decorator(ret => DefendType == DefendUnitType.Unit, new PrioritySelector( new Decorator(ret => ((EscortUntil == EscortUntilType.DestinationReached) && (Me.Location.Distance(EscortDestination) <= DestinationTolerance)), new Action(delegate { TreeRoot.StatusText = "Finished!"; _isBehaviorDone = true; })), // If quest is completed, we're done... new Decorator(ret => ((EscortUntil == EscortUntilType.QuestComplete) && Me.IsQuestComplete(QuestId)), new Sequence( new Action(ret => TreeRoot.StatusText = "Finished!"), new WaitContinue(120, new Action(delegate { _isBehaviorDone = true; return RunStatus.Success; })) )), new Decorator(ret => DefendObject == null, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving To Location - X: " + Location.X + " Y: " + Location.Y), new Action(ret => Navigator.MoveTo(Location)), new Sleep(300) ) ), new Decorator(ret => Me.CurrentTarget != null && Me.CurrentTarget.IsFriendly, new Action(ret => Me.ClearTarget())), new Decorator( ret => EnemyList.Count > 0 && EnemyList[0].IsHostile, new PrioritySelector( new Decorator( ret => Me.CurrentTarget != EnemyList[0], new Sequence( new Action(ctx => EnemyList[0].Target()), new SleepForLagDuration())), new Decorator( ret => !Me.Combat, new PrioritySelector( new Decorator( ret => RoutineManager.Current.PullBehavior != null, RoutineManager.Current.PullBehavior), new Action(ret => RoutineManager.Current.Pull()))))), new Decorator( ret => DefendObject != null && (!Me.Combat || Me.CurrentTarget == null || Me.CurrentTarget.IsDead) && DefendObject.DistanceSqr > 5f * 5f, new Sequence( new Action(ret => TreeRoot.StatusText = "Following Mob - " + DefendObject.SafeName + " At X: " + DefendObject.X + " Y: " + DefendObject.Y + " Z: " + DefendObject.Z), new Action(ret => Navigator.MoveTo(DefendObject.Location)), new Sleep(100) ) ), new Decorator(ret => EnemyList.Count > 0 && (Me.Combat || EnemyList[0].Combat), new PrioritySelector( new Decorator( ret => Me.CurrentTarget == null, new Sequence( new Action(ret => EnemyList[0].CurrentTarget.Target()), new SleepForLagDuration())), new Decorator( ret => !Me.Combat, new PrioritySelector( new Decorator( ret => RoutineManager.Current.PullBehavior != null, RoutineManager.Current.PullBehavior), new Action(ret => RoutineManager.Current.Pull()))))))), #endregion #region DefendType ObjectTimer new Decorator(ret => DefendType == DefendUnitType.ItemStartTimer, new PrioritySelector( new Decorator(ret => ((EscortUntil == EscortUntilType.DestinationReached) && (Me.Location.Distance(EscortDestination) <= DestinationTolerance)), new Action(delegate { TreeRoot.StatusText = "Finished!"; _isBehaviorDone = true; })), // If quest is completed, we're done... new Decorator(ret => ((EscortUntil == EscortUntilType.QuestComplete) && Me.IsQuestComplete(QuestId)), new Sequence( new Action(ret => TreeRoot.StatusText = "Finished!"), new WaitContinue(120, new Action(delegate { _isBehaviorDone = true; return RunStatus.Success; })) )), new Decorator(ret => DefendObject == null, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving To Location - X: " + Location.X + " Y: " + Location.Y), new Action(ret => Navigator.MoveTo(Location)), new Sleep(300) ) ), new Decorator(ret => DefendObject != null && DefendObject.WithinInteractRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Using Item"), new Action(ret => Item.UseContainerItem()), new Action(ret => TimeOut.Start()) ) ), new Decorator(ret => TimeOut.ElapsedMilliseconds >= 300000 && !DefendObject.WithinInteractRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving To Object : " + DefendObject.Location.Distance(Me.Location)), new Action(ret => Navigator.MoveTo(DefendObject.Location)), new Sleep(300) ) ), new Decorator(ret => TimeOut.ElapsedMilliseconds >= 300000 && DefendObject.WithinInteractRange, new Sequence( new Action(ret => DefendObject.Interact()), new Sleep(500), new Action(ret => Lua.DoString("SelectGossipOption(1)")), new Action(ret => TimeOut.Reset()) ) ), new Decorator(ret => Me.CurrentTarget != null && Me.CurrentTarget.IsFriendly, new Action(ret => Me.ClearTarget())), new Decorator( ret => EnemyList.Count > 0 && EnemyList[0].IsHostile, new PrioritySelector( new Decorator( ret => Me.CurrentTarget != EnemyList[0], new Sequence( new Action(ret => EnemyList[0].Target()), new SleepForLagDuration())), new Decorator( ret => !Me.Combat, new PrioritySelector( new Decorator( ret => RoutineManager.Current.PullBehavior != null, RoutineManager.Current.PullBehavior), new Action(ret => RoutineManager.Current.Pull()))))), new Decorator( ret => DefendObject != null && (!Me.Combat || Me.CurrentTarget == null || Me.CurrentTarget.IsDead) && DefendObject.DistanceSqr > 5f * 5f, new Sequence( new Action(ret => TreeRoot.StatusText = "Following Mob - " + DefendObject.SafeName + " At X: " + DefendObject.X + " Y: " + DefendObject.Y + " Z: " + DefendObject.Z), new Action(ret => Navigator.MoveTo(DefendObject.Location)), new Sleep(100) ) ), new Decorator(ret => EnemyList.Count > 0 && (Me.Combat || EnemyList[0].Combat), new PrioritySelector( new Decorator( ret => Me.CurrentTarget == null, new Sequence( new Action(ret => EnemyList[0].CurrentTarget.Target()), new SleepForLagDuration())), new Decorator( ret => !Me.Combat, new PrioritySelector( new Decorator( ret => RoutineManager.Current.PullBehavior != null, RoutineManager.Current.PullBehavior), new Action(ret => RoutineManager.Current.Pull()))))))) #endregion ) )); }
/// <summary> /// Changes the turn of user. /// </summary> public void ChangeTurn() { DefendObject.SetActive(false); // pileCardManger.HideColorAfterWhot (); playerTurn = !playerTurn; UpdateUserAreaAndMsg(); if (WhotConstants.isAI) { if (PlayAITurn()) { turnMsg.SetActive(false); return; } else { turnMsg.SetActive(true); } } else { StartTimer(); } //Force player to pick from pile or throw the particular num if (!string.IsNullOrEmpty(activeRule)) { int lastCardIdNum = int.Parse(topCardPlayed.Substring(3, topCardPlayed.Length - 3)); switch (activeRule) { case "PickTwo": /*if (CheckCardNumberFromPlayerList(lastCardIdNum, GetActivePlayerList()) != "") * { * DefendObject.SetActive(true); * SoundManger.instance.PlaySound((int)(ListOfSounds.Defend)); * //highlight 2 rule ended * } * else * {*/ if (playerTurn) { whotAlerts.ShowAlert((int)AlertMsgName.Pick2Card); } // } break; case "PickThree": if (CheckCardNumberFromPlayerList(lastCardIdNum, GetActivePlayerList()) != "") { DefendObject.SetActive(true); //highlight 5 SoundManger.instance.PlaySound((int)(ListOfSounds.Defend)); } else { if (playerTurn) { whotAlerts.ShowAlert((int)AlertMsgName.Pick3Card); } //Force pick from pile } break; case "GeneralMarket": //Force pick from pile // playerDisable.SetActive(false); //Commented on 17th feb to enable scroll //opponentDisable.SetActive (false); goMarket.SetActive(true); if (playerTurn) { whotAlerts.ShowAlert((int)AlertMsgName.GoMarket); } break; } } }