예제 #1
0
 // Use this for initialization
 void Start()
 {
     phase = 0;
     //Get the local instance of State Handler
     state = (StateHandler)GameObject.FindWithTag("State Machine").GetComponent(typeof(StateHandler));
     //Initialize
     //  Partymember * n
     partyMembers = new PlayerEntity[state.PartySize];
     for (int i = 0; i < state.PartySize; i++) //Loops through and instantiates all party members
     {
         if (state.PartyMember(i) != null)     //Checks if the member is null to avoid error
         {
             /**************This needs to be fixed later to appropriatly space players*******************/
             //  formula will be ((i + 1)*(screen.width/players.length))-(screen.width/2)
             //  not sure how to get screen size in the unity units to properly translate though
             partyMembers[i] = Instantiate(state.PartyMember(i), new Vector2(-5 + 3.334f * i, -1.3f), Quaternion.identity);
             if (state.PartyMember(i).Stats.IsAlive == true && activeMember == -1)//If its the first alive member set to active
             {
                 activeMember = i;
             }
         }
         else
         {
             Debug.LogWarning("Tried to instantiate null party member at index: " + i);
         }
     }
     //  Enemy * n
     enemies = new EnemyEntity[state.EnemySize];
     for (int i = 0; i < state.EnemySize; i++)
     {
         if (state.EnemyMember(i) != null)
         {
             /**************This needs to be fixed later to appropriatly space enemies*******************/
             // same formula as above
             enemies[i] = Instantiate(state.EnemyMember(i), new Vector2(-5 + 3.334f * i, -1.3f), Quaternion.identity);
         }
         else
         {
             Debug.LogWarning("Tried to instantiate null enemy member at index: " + i);
         }
     }
     phase = 1;
 }