public static CCActionMoveBoat GetSSAction(GameObject obj, Vector3 target, float speed) { CCActionMoveBoat action = ScriptableObject.CreateInstance <CCActionMoveBoat> (); action.gameobject = obj; action.target = target; action.speed = speed; return(action); }
public bool MoveBoat() { int totalOnBoat; totalOnBoat = BoatDevils.Count + BoatPriests.Count; /*when the boat move we should think about two aspects. * One is the place where you start from.In this case , you should count the * Priests and Devils on it. * The other one is the place where you want to reach.For this , you should * count the Priests and Devils over there and both on boat. * Below lists the two cases.The first is from east to west.(BoatPositionTwo<-BoatPositionOne) * The second is from west to east(BoatPositionTwo->BoatPositionOne)*/ if (Boat.transform.position.Equals(BoatPositionOne)) { totalOnBoat = BoatDevils.Count + BoatPriests.Count; IsBoatRunning = false; if (totalOnBoat > 0 && totalOnBoat <= 2) { IsBoatRunning = true; PositionBoatWillGoTo = BoatPositionTwo; CCActionMoveBoat moveBoat = CCActionMoveBoat.GetSSAction(Boat, PositionBoatWillGoTo, 0.25f); actionManager.RunAction(moveBoat, null); // Boat.transform.position = Vector3.MoveTowards (Boat.transform.position,PositionBoatWillGoTo,0.25f); /*in MoveBoat() method may appear failed result so we need to check it */ checkResult(); } } else if (Boat.transform.position.Equals(BoatPositionTwo)) { totalOnBoat = BoatDevils.Count + BoatPriests.Count; IsBoatRunning = false; if (totalOnBoat > 0 && totalOnBoat <= 2) { IsBoatRunning = true; PositionBoatWillGoTo = BoatPositionOne; CCActionMoveBoat moveBoat = CCActionMoveBoat.GetSSAction(Boat, PositionBoatWillGoTo, 0.25f); actionManager.RunAction(moveBoat, null); // Boat.transform.position = Vector3.MoveTowards (Boat.transform.position,PositionBoatWillGoTo,0.25f); checkResult(); } } Debug.Log("Direction:" + PositionBoatWillGoTo.x + " StartPriest:" + StartPriests.Count + " StartDevils:" + StartDevils.Count + " BoatPriests" + BoatPriests.Count + " BoatDevils:" + BoatDevils.Count + " EndPriests:" + EndPriests.Count + " EndDevils:" + EndDevils.Count); return(false); }