void OnTriggerEnter(Collider other) { switch (other.gameObject.tag) { case "EastBankBoatSpot": boat_state = BoatState.EastBank; // Debug.Log ("Arrived on EastBank"); moving = false; PlayerScript.beStill = false; otherBank = BoatState.WestBank; OnBoatLand("east"); //GameManager_FailureChecker.CheckSuccess(); break; case "WestBankBoatSpot": boat_state = BoatState.WestBank; // Debug.Log ("Arrived on WestBank"); moving = false; PlayerScript.beStill = false; otherBank = BoatState.EastBank; //all of the animals subscribe to this event OnBoatLand("west"); GameManager_FailureChecker.CheckSuccess(); break; default: break; } }
/// <summary> /// /// </summary> /// <param name="Name"></param> /// <param name="nMiss">Number of Missionaries within the current state</param> /// <param name="nCan">Number of Cannibals within the current state</param> /// <param name="BoatOnTheSide">An indication of the banks at which the boat is</param> /// <param name="stateLevel"></param> /// <param name="Cost"></param> public State(int nMiss, int nCan, BoatState BoatOnTheSide, int stateLevel = 0, int NumOfEachAtStart = 3, int Cost = 0) : this(nMiss, nCan, BoatOnTheSide, null, stateLevel, NumOfEachAtStart, Cost) { ; }
// Update is called once per frame void Update() { // Change the state to the player not in boat state if the player isn't in the boat if (PlayerStateMachine.Instance.state != PlayerStateMachine.PlayerState.BOAT) { State = BoatState.PLAYER_NOT_IN_BOAT; } // Change what happens depending on the state switch (State) { case BoatState.IN_OCEAN: UpdateInOceanState(); break; case BoatState.IN_SHALLOW_WATER: UpdateInShallowWaterState(); break; case BoatState.PLAYER_NOT_IN_BOAT: UpdatePlayerNotInBoatState(); break; default: break; } }
// Get clicked position private void TargetPosition() { //float distance; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "Sea" && boatCurrentState != BoatState.RESCUE) { if (Input.GetMouseButton(0) && timeToClick <= 0) { _targetPosition = new Vector3(hit.point.x, 0, hit.point.z); boatCurrentState = BoatState.SAIL; } } else if (hit.transform.tag == "Dock" && boatCurrentState != BoatState.RESCUE) { if (Input.GetMouseButtonDown(0) && timeToClick <= 0) { _targetPosition = new Vector3(hit.point.x, 0, hit.point.z); boatCurrentState = BoatState.DOCK; } } else if (hit.transform.tag == "Animal" && boatCurrentState != BoatState.RESCUE) { if (Input.GetMouseButtonDown(0) && timeToClick <= 0) { FindObjectOfType <AudioManager>().Play("BirdWhistle"); _targetPosition = new Vector3(hit.point.x, 0, hit.point.z); boatCurrentState = BoatState.RESCUE; } } } }
private void UpdatePlayerNotInBoatState() { if (PlayerStateMachine.Instance.state == PlayerStateMachine.PlayerState.BOAT) { State = BoatState.IN_SHALLOW_WATER; } }
/// <summary> /// Constructor. /// </summary> /// <param name="p_Cells">List of cells to be converted into a boat.</param> public Boat(List <Cell> p_Cells) { Cells = p_Cells; State = BoatState.Healthy; foreach (var cell in p_Cells) { cell.ParentBoat = this; } if (Cells.Count == 4) { Type = BoatType.Battleship; } else if (Cells.Count == 3) { Type = BoatType.Cruiser; } else if (Cells.Count == 2) { Type = BoatType.Destroyer; } else if (Cells.Count == 1) { Type = BoatType.Torpedoboat; } else { //TODO //AliensShip in our Fleet! } }
public void reset() { boat.transform.position = fromPosition; to_or_from = BoatState.From; for (int i = 0; i < passenger.Length; i++) { passenger[i] = null; } }
public void SetState(BoatState pState) { if (_abstractState != null) { _abstractState.Refresh(); } _abstractState = _stateCache[pState]; _abstractState.Start(); }
/// <summary> /// Marks all the child cells as dead. /// </summary> void Die() { State = BoatState.Dead; foreach (var cell in Cells) { cell.Style = CellStyle.DeadCell; } }
// Use this for initialization void Start() { #if UNITY_EDITOR speed = 10; #endif boat_state = BoatState.EastBank; otherBank = BoatState.WestBank; }
/// <summary> /// Sets the state of the boat after shoot. /// </summary> /// <param name="p_Cell"></param> public void Shoot(Cell p_Cell) { p_Cell.Style = CellStyle.WoundedCell; State = BoatState.Wounded; if (Cells.All(c => c.Style == CellStyle.WoundedCell)) { this.Die(); } }
/// <inheritdoc /> public void UpdateBoatStatus(int boatId, BoatState status) { var boat = _context.SailingBoats.FirstOrDefault(b => b.Id == boatId); if (boat != null) { boat.Status = (int)status; } _context.SaveChanges(); }
public static string PositionAsString(this BoatState state) { switch (state) { case BoatState.Left: return("<-BOAT LEFT"); case BoatState.Right: return("BOAT RIGHT->"); } return(string.Empty); }
/// <summary> /// We use this in problem processing. /// </summary> /// <param name="state"></param> /// <returns></returns> public static int AsMultiplier(this BoatState state) { switch (state) { case BoatState.Left: return(-1); case BoatState.Right: return(1); } return(0); }
public static BoatState Inverse(this BoatState state) { switch (state) { case BoatState.Left: return(BoatState.Right); case BoatState.Right: return(BoatState.Left); } return(BoatState.Left); }
public void GenGameObjects() { Shore_l = GameObject.CreatePrimitive(PrimitiveType.Cube); Shore_l.name = "Shore_l"; Shore_l.transform.localScale = new Vector3(10, 2, 1); Shore_l.transform.position = new Vector3(-17, -9, 0); Shore_r = Instantiate <GameObject>(Shore_l, new Vector3(17, -9, 0), Quaternion.identity); Shore_r.name = "Shore_r"; Shore_r.GetComponent <MeshRenderer>().material.color = Color.black; Shore_l.GetComponent <MeshRenderer>().material.color = Color.black; river = GameObject.CreatePrimitive(PrimitiveType.Cube); river.name = "river"; river.transform.localScale = new Vector3(44, 1, 1); river.transform.position = new Vector3(0, -10, 0); river.GetComponent <MeshRenderer>().material.color = Color.blue; boat = GameObject.CreatePrimitive(PrimitiveType.Cube);; boat.transform.localScale = new Vector3(3, 1, 1); boat.transform.position = Boat_Right; boat.name = "boat"; boat.GetComponent <MeshRenderer>().material.color = Color.green; GameObject temp_priest = GameObject.CreatePrimitive(PrimitiveType.Sphere); temp_priest.transform.localScale = new Vector3(1, 1, 1); temp_priest.AddComponent <On_Off>(); GameObject temp_devil = GameObject.CreatePrimitive(PrimitiveType.Cube); temp_devil.transform.localScale = new Vector3(1, 1, 1); temp_devil.AddComponent <On_Off>(); for (int i = 0; i < 3; i++) { On_Shore_r.Add(i, Instantiate <GameObject>(temp_priest, new Vector3(12.5f + i * gab, -7.5f, 0), Quaternion.identity)); On_Shore_r[i].name = i.ToString(); } for (int i = 3; i < 6; i++) { GameObject tmp = Instantiate <GameObject>(temp_devil, new Vector3(12.5f + i * gab, -7.5f, 0), Quaternion.identity); tmp.name = i.ToString(); tmp.GetComponent <Renderer>().material.color = Color.red; On_Shore_r.Add(i, tmp); } boat_capicity = 2; b_state = BoatState.STOPLEFT; Destroy(temp_devil); Destroy(temp_priest); }
public static string StatusAsString(this BoatState state) { switch (state) { case BoatState.Left: return("LEFT"); case BoatState.Right: return("RIGHT"); } return(string.Empty); }
IEnumerator CR_MoveAndRotate(Vector2 targetPos, Direction toDirection, System.Action completed = null) { //Start moving and rotating the model BoatState = BoatState.MoveAndRotate; var boxCollider = GetComponentInChildren <BoxCollider2D>(); boxCollider.enabled = false; Vector2 startPos = transform.position; float deltaAngle = GetDeltaAngle(currentDirection, toDirection); Quaternion startRot = isometricModel.transform.localRotation; //NOTE: must multiply by the rotation to create a local space rotation Quaternion endRot = Quaternion.AngleAxis(-deltaAngle, modelUp) * isometricModel.transform.localRotation; //Fire the moved position event if (OnBoatMovedPosition != null) { OnBoatMovedPosition(gameObject, targetPos); // This will update dictionary info when it's subscribed by the MapConstatnProvider } float t = 0; while (t < moveAndRotateTime) { t += Time.deltaTime; float fraction = t / moveAndRotateTime; rb2D.MovePosition(Vector2.Lerp(startPos, targetPos, fraction)); isometricModel.transform.localRotation = Quaternion.Lerp(startRot, endRot, fraction); yield return(null); } ////Fire the moved position event //if (OnBoatMovedPosition != null) // OnBoatMovedPosition(gameObject, targetPos); // This will update dictionary info when it's subscribed by the MapConstatnProvider boxCollider.enabled = true; //Update the current Direction currentDirection = toDirection; //Update boat state to idle after finishing moving and rotating BoatState = BoatState.Idle; //NOTE: After enable collider, we skip this frame to the box collider begin to check,because this boat can collide when box collider is enabled, check if the boat state is idle yield return(new WaitForSeconds(0.1f)); if (BoatState == BoatState.Idle) { if (completed != null) { completed(); } } }
public BoatController(Vector3 frompos, Vector3 topos) { to_or_from = BoatState.From; fromPosition = frompos; toPosition = topos; from_positions = new Vector3[] { new Vector3(frompos.x - 0.5f, frompos.y + 0.5f, 0), new Vector3(frompos.x + 0.5f, frompos.y + 0.5f, 0) }; to_positions = new Vector3[] { new Vector3(topos.x - 0.5f, topos.y + 0.5F, 0), new Vector3(topos.x + 0.5f, topos.y + 0.5F, 0) }; boat = Object.Instantiate(Resources.Load("Perfabs/Boat", typeof(GameObject)), fromPosition, Quaternion.identity, null) as GameObject; boat.name = "boat"; boat.AddComponent(typeof(ClickGui)); }
// If it collides with dock it enters DOCKED state private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Dock") { boatCurrentState = BoatState.DOCKED; } else if (collision.gameObject.tag == "Obstacle") { FindObjectOfType <AudioManager>().Play("RockHit"); FindObjectOfType <AudioManager>().Play("PointDeduct"); foreach (ContactPoint contact in collision.contacts) { Instantiate(dust, contact.point, Quaternion.identity); } } }
public void Move() { if (!hasPassenger()) { return; } if (to_or_from == BoatState.To) { move.setDest(fromPosition); to_or_from = BoatState.From; } else { move.setDest(toPosition); to_or_from = BoatState.To; } }
public Vector3 Move() { if (!hasPassenger()) { return(fromPosition); } if (to_or_from == BoatState.To) { to_or_from = BoatState.From; return(fromPosition); } else { to_or_from = BoatState.To; return(toPosition); } }
public State(int nMiss, int nCan, BoatState BoatOnTheSide, State PrevState, int stateLevel = 0, int NumOfEachAtStart = 3, int Cost = 0) { this._name = Name; this.nMiss = nMiss; this.nCan = nCan; this._boatOnTheSide = BoatOnTheSide; this._prevState = PrevState; this.stateLevel = stateLevel; this._cost = Cost + 1; if (_prevState != null) { this._cost += this._prevState.Cost; } State.NumOfEachAtStart = NumOfEachAtStart; }
private void Start() { _targetPosition = transform.position; boatCurrentState = BoatState.START; boatFuel = GetComponent <BoatFuel>(); boatStats = GetComponent <BoatStats>(); boatUpgrade = GetComponent <BoatUpgrade>(); boatColliders = gameObject.GetComponents <BoxCollider>(); //HealthBar.OnBirdRescueSuccess += BirdSaved; //HealthBar.OnBirdRescueFail += BirdDied; tutorial.SetActive(true); FindObjectOfType <AudioManager>().Play("Ocean"); FindObjectOfType <AudioManager>().Play("Engine"); FindObjectOfType <AudioManager>().Volume("Engine", 0.4f); FindObjectOfType <AudioManager>().Play("EngineStart"); }
private void Update() { game_state = check(); if (boat.transform.position == Boat_Right) { b_state = BoatState.STOPRIGHT; } else if (boat.transform.position == Boat_Left) { b_state = BoatState.STOPLEFT; } else { b_state = BoatState.MOVING; } for (int i = 0; i < 6; i++) { if (On_Shore_l.ContainsKey(i)) { On_Shore_l[i].transform.position = new Vector3(-12.5f - i * gab, -7.5f, 0); } if (On_Shore_r.ContainsKey(i)) { On_Shore_r[i].transform.position = new Vector3(12.5f + i * gab, -7.5f, 0); } } int signed = 1; for (int i = 6; i < 12; i++) { if (On_Boat.ContainsKey(i)) { On_Boat[i].transform.localPosition = new Vector3(signed * 0.3f, 1, 0); signed = -signed; } } }
protected virtual void GetDestroy() { if (BoatState == BoatState.Destroyed) { return; } BoatState = BoatState.Destroyed; //Effect and sound EffectManager.Instance.SpawnEffect(EffectManager.Instance.explosion, transform.position, Quaternion.identity); SoundManager.Instance.PlayDestroyShipSound(); //SpawnSkull(); MapConstantProvider.Instance.SpawnUnitOnDestroyedObject(skullPrefab, transform.position, gameObject); Observer.Instance.PostEvent(ObserverEventID.OnCantUndo); isometricModel.SetActive(false); }
public void Update() { game_state = check(); if (game_state == GameState.NOT_ENDED) { if (Boat.transform.position.x < 10 && Boat.transform.position.x > -10) { boat_state = BoatState.MOVING; } else if (Boat.transform.position.x >= 10) { boat_state = BoatState.STOPRIGHT; } else { boat_state = BoatState.STOPLEFT; } for (int i = 0; i < 6; i++) { if (On_Shore_r [i] != 6) { dp [On_Shore_r [i]].transform.position = new Vector3(25 - 2 * i, 3, 0); } if (On_Shore_l [i] != 6) { dp [On_Shore_l [i]].transform.position = new Vector3(-25 + 2 * i, 3, 0); } } if (On_Boat [0] != 6) { dp [On_Boat [0]].transform.position = new Vector3(Boat.transform.position.x - 2, 0.5f, 0); } if (On_Boat [1] != 6) { dp [On_Boat [1]].transform.position = new Vector3(Boat.transform.position.x + 2, 0.5f, 0); } } }
private void Update() { switch (_state) { case BoatState.NAVIGATING: if (Vector3.Distance(_destination.GetPosition(), transform.position) <= _destination.GetRange()) { if (_destination is Collectable) { SetState(BoatState.COLLECTING); _collecting = _destination as Collectable; _collectingTimer = _collecting.GetCollectingDuration(); } else { _state = BoatState.IDLE; } _destination.OnArive(this); _destination.SetSelected(false); SetSelected(false); _destination = null; } break; case BoatState.COLLECTING: _collectingTimer -= Time.deltaTime * _collectingSpeed; if (_collectingTimer <= 0) { _cargoWeight += _collecting.GetWeight(); GameObject gameObject = (_collecting as MonoBehaviour).gameObject; Destroy(gameObject); SetState(BoatState.IDLE); } break; } }
public static State Make(int nMiss, int nCan, BoatState BoatOnTheSide, State PrevState, int stateLevel = 0, int Cost = 0) { return(new State(nMiss, nCan, BoatOnTheSide, PrevState, stateLevel, numberOfEach, Cost)); }
public AbstractBoatState GetState(BoatState pState) { return(_stateCache[pState]); }