public void RemoveMoveInteraction(MoveInteraction group) { if (group.GetPlacedObject()) { foreach (Player p in group.players) { if (p != null) { StartCoroutine(p.DelayIsAvailableTrue()); } else { Debug.LogWarning("Some Player on GroupInteraction Destroy was NULL"); //TODO handle null-player interactions } } } else { group.SetAllPlayersAvailable(true); group.ResetAllPlayersFriendCounters(); } moveInteractionList.Remove(group); DestroyImmediate(group.gameObject); }
//CHANGES STATES according to the number of Players, which are logged in public virtual void CheckPlayerNr() { //ROTATE Mode: 1 player if (playersActive == 1) { timeEntered = Time.time; } else { timeEntered = 360000f; //TODO find a way to check time correctly } //WAIT Mode: too little player if (playersActive > 0 && playersActive < max_PlayerNr) { Debug.Log("WAIT Mode activated"); ChangeState(ElementState.WAIT); } //MOVE Mode: maximum player else if (playersActive == max_PlayerNr) { ChangeState(ElementState.MOVE); movInt = interactionManager.AddMoveInteraction(this, playerArray); Debug.Log("MOVE State activated"); } //ACTIVE Mode: 0 player else if (playersActive == 0) { ChangeState(ElementState.ACTIVE); } }
/**Updates the current interacting groups as soon as any player sends a triggerExit event with another player*/ /* * public void GroupInteractionOnPlayerCollisionExit(Player player1, Player player2) * { * GroupInteraction groupInteraction1 = FindPlayerInGroups(player1); * if (groupInteraction1 != null) * { * GroupInteraction groupInteraction2 = FindPlayerInGroups(player2); * if (groupInteraction2 != null) * { * //both players are in the same group, and it is a CREATING group * if (groupInteraction1 == groupInteraction2 && groupInteraction1.GetComponent<CreateInteraction>()) * { * //if player1 is still connected to the group * if (player1.GetFriendCounter() > 1) * { * //both players are still connected to the group * if (player2.GetFriendCounter() > 1) * { * //do nothing because the group is the same as before * } * //only player1 is connected, player2 is leaving * else * { * groupInteraction1.RemovePlayer(player2); * } * } * //only player2 is connected, player1 is leaving * else if (player2.GetFriendCounter() > 1) * { * groupInteraction2.RemovePlayer(player1); * } * //player1 and player2 are the two players left in the creating group * else * { * groupInteraction1.ResetAllPlayersFriendCounters(); * groupInteraction1.SetAllPlayersAvailable(true); * RemoveCreateInteraction(groupInteraction1); * } * } * //players are in different groups (e.g. 2 and 3 players walk over each others triggers) * else * { * //TODO: handle this or do nothing * } * } * //player1 is part of a "full" group. player2 is not in a group and leaves group from p1 * //else {//do nothing} * } * //player1 is not in a group and leaves from WHERE?? is this even possible? * //else {//do nothing} * } */ public void AddMoveInteraction(AbstractOpticalElement opticalElement, Player[] players) { Debug.Log("AddMoveInteraction"); MoveInteraction newGroupInteraction = Instantiate(MIPrefab); newGroupInteraction.SetProperties(players, opticalElement); moveInteractionList.Add(newGroupInteraction); }
public void ClearInteractions() { if (rotInt != null) { interactionManager.RemoveRotationInteraction(rotInt); rotInt = null; } if (movInt != null) { interactionManager.RemoveMoveInteraction(movInt); movInt = null; } }
public void RemoveMoveInteraction(MoveInteraction group) { // reset place animation group.opticalElement.waitCircle.fillAmount = 0; moveInteractionList.Remove(group); bool placed = group.PlaceObject(); if (placed) { group.StartCoroutine(group.DelayedDestroy()); } else { Destroy(group); } }