Esempio n. 1
0
        //返回值是插入的位置
        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);
        }
Esempio n. 2
0
 public void reset()
 {
     boatStatus = 0;
     movescript.Move(new Vector3(4, 0, 0));
     frontCharacter = null;
     backCharacter  = null;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 //下船需要的支持
 public void OffBoat(ICharacterController element)
 {
     element.character.transform.parent = null;
     if (frontCharacter == element)
     {
         frontCharacter = null;
     }
     else
     {
         backCharacter = null;
     }
 }
Esempio n. 5
0
 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;
         }
     }
 }
Esempio n. 6
0
 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;
         }
     }
 }
Esempio n. 7
0
        //返回插入的位置
        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);
        }
Esempio n. 8
0
        //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);
                }
            }
        }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
        //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);
                }
            }
        }
Esempio n. 11
0
 public void OffCoast(ICharacterController Mycharacter)
 {
     storage.delete(Mycharacter);
 }
Esempio n. 12
0
 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);
 }