//返回值是插入的位置 public int insert(ICharacterController element) {/* * Debug.Log("class storage in function insert"); * Debug.Log("output all element"); * for(int i=0;i<6;i++) * { * if (characterStorage[i] == null) * Debug.Log("null"); * else * { * Debug.Log(element.character.name); * } * }*/ if (this.isFull()) { return(-1); } for (int i = 0; i < 6; i++) { if (characterStorage[i] == null) { characterStorage[i] = element; return(i); } } return(-1); }
public void reset() { boatStatus = 0; movescript.Move(new Vector3(4, 0, 0)); frontCharacter = null; backCharacter = null; }
public BoatController() { boat = Object.Instantiate(Resources.Load("Prefabs/boat", typeof(GameObject))) as GameObject; boat.name = "boat"; movescript = boat.AddComponent(typeof(MoveController)) as MoveController; boat.AddComponent(typeof(UserClick)); boatStatus = 0; frontCharacter = null; backCharacter = null; }
//下船需要的支持 public void OffBoat(ICharacterController element) { element.character.transform.parent = null; if (frontCharacter == element) { frontCharacter = null; } else { backCharacter = null; } }
public void delete(ICharacterController character) { for (int i = 0; i < 6; i++) { if (characterStorage[i] == null) { continue; } else if (characterStorage[i] == character) { characterStorage[i] = null; return; } } }
public void delete(ICharacterController character) { //Debug.Log("class CoastStorage in function delete with parameter:" + character.ToString()); for (int i = 0; i < 6; i++) { if (characterStorage[i] == null) { continue; } else if (characterStorage[i] == character) { characterStorage[i] = null; return; } } }
//返回插入的位置 public int insert(ICharacterController element) { if (this.isFull()) { return(-1); } for (int i = 0; i < 6; i++) { if (characterStorage[i] == null) { characterStorage[i] = element; return(i); } } return(-1); }
//OnBoat和OffBoat,负责操控船的数据结构,同时负责管理移动 public void OnBoat(ICharacterController element) { if (this.boatFull()) { return; } if (boatStatus == 0)//从from向to,front为前 { if (frontCharacter == null) { //Debug.Log("from->to:front element in boat"); frontCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, front); } else { //Debug.Log("from->to:back element in boat"); backCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, back); } } else // 从to开向from,back为前 { if (backCharacter == null) { //Debug.Log("to->from:back element in boat"); backCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, back); } else { //Debug.Log("to->from:front element in boat"); frontCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, front); } } }
public int OnCoast(ICharacterController character, int boatStatus) { if (storage.isFull()) { return(-1); } else { int pos = storage.insert(character); Vector3 relativeVec; if (coast.name == "from_coast") { relativeVec = new Vector3(2.5f - pos, 1.25f, 0); } else { relativeVec = new Vector3(-2.5f + pos, 1.25f, 0); } character.moveOffBoat(coast.transform.position, boatStatus, relativeVec); return(pos); } }
//OnBoat和OffBoat,负责操控船的数据结构,同时负责管理移动 public void OnBoat(ICharacterController element) { if (this.boatFull()) { return; } if (boatStatus == 0)//从from向to,front为前 { if (frontCharacter == null) { frontCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, front); } else { backCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, back); } } else // 从to开向from,back为前 { if (backCharacter == null) { backCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, back); } else { frontCharacter = element; element.character.transform.parent = boat.transform; element.moveOnBoat(boat.transform.position, boatStatus, front); } } }
public void OffCoast(ICharacterController Mycharacter) { storage.delete(Mycharacter); }
public void OffCoast(ICharacterController Mycharacter) { //Debug.Log("In function OffCoast 2 with parameter:" + Mycharacter.character.ToString()); //Debug.Log("check storage:" + (storage == null)); storage.delete(Mycharacter); }