protected override void ProcessStopDrag(Position dropGridPosition) { if (dropGridPosition != null) { AddFruitonToTeam(draggedFruiton, dropGridPosition, myTeam); } MyTeamGrid.LoadTeam(myTeam, dbFridgeMapping); }
/// <summary> /// Add a fruiton to currently selected team. /// </summary> /// <param name="fruiton">fruiton to add</param> /// <param name="position">position in team where the fruiton should be added</param> private void AddFruitonToTeam(Fruiton fruiton, Position position) { FridgeFruiton fridgeFruiton = dbFridgeMapping[fruiton.dbId]; fridgeFruiton.Count--; var team = teams[selectedTeamIndex].KernelTeam; team.FruitonIDs.Add(fruiton.dbId); team.Positions.Add(position); MyTeamGrid.AddFruitonAt(fruiton, position); }
public void TurnOffDrafting() { isMyTurnToDraft = false; MyTeamGrid.AvailablePositions = null; MyTeamGrid.CancelHighlights(); MyTeamGrid.AllowEdit = false; MyName.color = Color.black; OpponetTurnToPickText.gameObject.SetActive(true); TimeToPickText.gameObject.SetActive(false); TimeToPickLabel.gameObject.SetActive(false); }
private void AddFruitonToTeam(KFruiton fruiton, Position position, FruitonTeam team) { if (isMyTurnToDraft) { FridgeFruiton fridgeFruiton = dbFridgeMapping[fruiton.dbId]; fridgeFruiton.Count--; team.FruitonIDs.Add(fruiton.dbId); team.Positions.Add(position); MyTeamGrid.AddFruitonAt(fruiton, position); draftHandler.SendDraftResponse(fruiton.dbId); } }
/// <summary> /// Hides fruiton detail, adds selected fruiton to the team. /// </summary> protected override void AddToTeamButtonListener() { HideDetail(); var availablePositions = MyTeamGrid.GetAvailableSquares(FruitonDetail.CurrentFruiton); if (availablePositions.Count == 1) { AddFruitonToTeam(FruitonDetail.CurrentFruiton, availablePositions[0]); } else { isAddingFromDetail = true; BeginFruitonDrag(FruitonDetail.CurrentFruiton); } }
public void TurnOnDrafting(DraftRequest request) { isMyTurnToDraft = true; currentDraftPosition = request.Position; MyTeamGrid.AvailablePositions = new List <Position> { currentDraftPosition }; MyTeamGrid.CancelHighlights(); MyTeamGrid.AllowEdit = true; MyName.color = Color.red; float pickTimeLeft = request.SecondsToPick - pickTimeFrame; pickTimeEnd = DateTime.Now.AddSeconds(pickTimeLeft); OpponetTurnToPickText.gameObject.SetActive(false); TimeToPickText.gameObject.SetActive(true); TimeToPickLabel.gameObject.SetActive(true); }
public void UpdateFruitonInMyTeam(DraftResult result) { var pos = myTeam.Positions.IndexOf(result.Position); if (pos == -1) { // Just add it myTeam.FruitonIDs.Add(result.FruitonId); myTeam.Positions.Add(result.Position); MyTeamGrid.LoadTeam(myTeam, dbFridgeMapping); } else if (myTeam.FruitonIDs[pos] != result.FruitonId) { // Update it myTeam.FruitonIDs[pos] = result.FruitonId; MyTeamGrid.LoadTeam(myTeam, dbFridgeMapping); } }
/// <summary> /// Cancels drag and drop, moves fruiton to gived position or removes it from the team. /// </summary> /// <param name="dropGridPosition">position in team grid where fruiton was dropped, /// null if fruiton was dropped outside of the team grid</param> protected override void ProcessStopDrag(Position dropGridPosition) { if (isDraggingFromTeam) { if (dropGridPosition == null) { RemoveTeamMember(teamDragGridPosition); } else { SwapTeamMembers(teamDragGridPosition, dropGridPosition); } } else if (dropGridPosition != null) { AddFruitonToTeam(draggedFruiton, dropGridPosition); } MyTeamGrid.LoadTeam(teams[selectedTeamIndex].KernelTeam, dbFridgeMapping); }
protected override void Start() { base.Start(); myTeam = new FruitonTeam(); enemyTeam = new FruitonTeam(); InitializeAllFruitons(); MyTeamGrid.LoadTeam(myTeam, dbFridgeMapping); EnemyTeamGrid.LoadTeam(enemyTeam, null); SetupView(); InitializeTeamGridListeners(); InitializeFruitonDetailListeners(); DragAndDropFruiton.gameObject.SetActive(false); TurnOffDrafting(); if (!ChallengeController.Instance.IsChallengeActive) { FindGame(); } }
/// <summary> /// Selects and loads fruiton team to team grid. /// </summary> /// <param name="index">index of selected team</param> private void SelectTeam(int index) { var isValidTeamIndex = IsValidTeamIndex(index); ButtonPlay.interactable = isValidTeamIndex || canPlayWithoutTeamSelected; ButtonEdit.interactable = isValidTeamIndex; ButtonDelete.interactable = isValidTeamIndex; if (!isValidTeamIndex) { selectedTeamIndex = -1; CurrentFruitonTeam = null; MyTeamGrid.ResetTeam(); return; } if (selectedTeamIndex >= 0) { var lastSelectedTeam = teams[selectedTeamIndex]; lastSelectedTeam.gameObject.GetComponent <Image>().color = lastSelectedTeam.Valid ? FridgeFruitonTeam.COLOR_DEFAULT : FridgeFruitonTeam.COLOR_INVALID; } teams[index].gameObject.GetComponent <Image>().color = FridgeFruitonTeam.COLOR_SELECTED; selectedTeamIndex = index; var newTeam = teams[selectedTeamIndex].KernelTeam; InputTeamName.text = newTeam.Name; CurrentFruitonTeam = newTeam; Dictionary <int, FridgeFruiton> passedDictionary = dbFridgeMapping; if (state != TeamManagementState.TEAM_MANAGEMENT) { passedDictionary = null; } MyTeamGrid.LoadTeam(newTeam, passedDictionary); }