public MoveToAction(GameObject actor, GameObject target, float maximumDistance, float minimumDistance, bool sitDown, bool turnToFaceTarget, bool turnToMatchWaypoint, bool follow) : base(actor) { this.target = target; if (target == null){ Debug.LogError("MoveToAction.MoveToAction(): " + actor.name + " Can't move to a null target!"); } Debug.Log("MoveToAction.MoveToAction():" + actor.name + " target: " + target.name + ", " + target.transform.position); this.maximumDistance = maximumDistance; this.minimumDistance = minimumDistance; this.sitDown = sitDown; this.turnToFaceTarget = turnToFaceTarget; this.turnToMatchWaypoint = turnToMatchWaypoint; this.follow = follow; standUpAction = null; walkToAction = null; }
protected override void UpdateFirstRound() { bool needToStandUp; bool needToWalk; bool needToTurn; bool needToSitDown; GameObject walkTarget = target; Seat currentSeat = state.GetCurrentSeat(); Seat targetSeat = null; if (sitDown){ targetSeat = (Seat)target.GetComponent("Seat"); if (currentSeat == targetSeat){ needToStandUp = false; needToWalk = false; needToTurn = false; needToSitDown = false; } else { needToStandUp = currentSeat != null; needToWalk = true; needToTurn = true; needToSitDown = true; walkTarget = targetSeat.GetWaypoint().gameObject; } } else { needToStandUp = currentSeat != null; needToWalk = true; needToTurn = turnToFaceTarget || turnToMatchWaypoint; needToSitDown = false; } if (needToStandUp){ QueueAction(standUpAction = new StandUpAction(actor, currentSeat)); } if (needToWalk){ if(CharacterManager.IsCharacter(target)) { QueueAction(walkToAction = new WalkToAction(actor, target, maximumDistance, minimumDistance, follow)); } else { QueueAction(walkToAction = new WalkToAction(actor, walkTarget, maximumDistance, minimumDistance, follow)); } } if (needToTurn){ if (turnToFaceTarget){ QueueAction(new TurnToFaceAction(actor, target)); } else if (turnToMatchWaypoint){ QueueAction(new TurnToMatchAction(actor, target)); } } if (needToSitDown){ QueueAction(new SitDownAction(actor, targetSeat)); } }