// Use this for initialization void Start() { bm = GetComponent <BoatMove>(); stamina = maxStamina; GetComponentInParent <PlayerInput>().leftTriggerClicked += OarPulled; GetComponentInParent <PlayerInput>().rightTriggerClicked += OarPulled; }
// 右端から出発 public void Departure(int boatNum) { if (BoatsAlive [boatNum]) { BoatMove move = Boats [boatNum].GetComponent <BoatMove> (); GameObject boat = Boats [boatNum]; GameObject mouseCheck; if (BoatArray[boatNum].Outward) // 往路 { move.setXSpeed(StratSpeed); if (!BoatArray [boatNum].Go) { BoatArray [boatNum].Go = true; StageBoat += 1; } } else if (BoatArray[boatNum].HaveTreashre) // 復路 { move.setXSpeed((-StratSpeed) - (float)(BoatArray[boatNum].Count * 0.005)); //Debug.Log ("Speed:" + move.xSpeed); } else { move.setXSpeed(0); } // 左端についた時の処理 if (boat.transform.position.x < -3.7f) { //Debug.Log ("stop"); move.setXSpeed(0); BoatArray[boatNum].Outward = false; // 船をクリックしたら帰る mouseCheck = getClickObject(); if (mouseCheck != null && mouseCheck == boat) { boat.transform.position = new Vector3(-3.6f, boat.transform.position.y, 0); boat.transform.Rotate(new Vector3(0, 180, 0)); BoatArray [boatNum].Second = 0; BoatArray [boatNum].HaveTreashre = true; } } // 初期位置に戻る if (boat.transform.position.x >= 6) { boat.transform.Rotate(new Vector3(0, 180, 0)); boat.transform.position = new Vector3(5, boat.transform.position.y, 0); BoatArray[boatNum].HaveTreashre = false; BoatArray[boatNum].Outward = true; BoatArray [boatNum].Go = false; BoatsAlive[boatNum] = true; StageBoat -= 1; } } }
public BoatController() { Boat = UnityEngine.Object.Instantiate(Resources.Load("Prefabs/Boat", typeof(GameObject))) as GameObject; Boat.name = "Boat"; pos1 = false; pos2 = false; MoveApi = Boat.AddComponent(typeof(BoatMove)) as BoatMove; Boat.AddComponent(typeof(ClickGUI)); }
void Awake() { instance = this; }
//float speed = 1f; private void Awake() { manage = this; }