public void EndTurn() { if (gameAction.action == ActionType.Nothing) { ShowMessage("<color=red>You did not select an action for the turn!</color>", true); return; } else if (gameAction.action == ActionType.ResearchTechnology && gameAction.val1 == 255) { ShowMessage("<color=red>You did not select the technology to research!</color>", true); return; } else if (gameAction.action == ActionType.BuildImprovement) { if (gameAction.val2 == 255) { ShowMessage("<color=red>You did not select the improvement to build!</color>", true); return; } if (gameAction.val1 == 255) { ShowMessage("<color=red>You did not select the city where to build the improvement!</color>", true); return; } } engine.EndTurn(game.multiplayer, GD.thePlayer.ID, gameAction); // Disable endturn, and hide all views EndTurnButton.enabled = false; HideAllViews(); playerAction = PlayerAction.Nothing; wtf = WhatTheFuckStatus.GetLost; // Show the short version of the selected action ShowMessage("Action:\n" + gameAction.Display()); }
private void PlayEndTurn() { // We call this function only if we receive a message from the engine telling that the turn is ended. // We just play all the actions that are happening, until completed. Then we go back to the normal user interaction status HideAllViews(); ShowMessage("Results of the turn..."); GD.DebugLog("Processing next turn", GD.LT.Debug); // First reset the messages and the completed and endturn foreach (Transform t in Players) { Enemy en = t.GetComponent <Enemy>(); if (en == null) { continue; } Transform completed = t.Find("TurnCompleted"); if (completed != null) { completed.GetComponent <Image>().color = ColorInvisible; } en.HideBalloon(); } // Next city increase/decrease for (int i = 0; i < turn.cities.Length; i++) { if (turn.cities[i] == null) { continue; } CityVals cv = turn.cities[i]; if (cv.pos == 255 || (cv.status != CityStatus.Owned && cv.status != CityStatus.Radioactive)) { continue; } cities[i].SetValues(cv); } // FIXME at this point we cannot do everything here. We may need to use the Update() and play all actions wtf = WhatTheFuckStatus.PlayReceivedActions; // -> Techs and Improvements done // -> GameActions // Then go in order for the players and run the action of each one, showing what is going on on a message // Check for win/loss // FIXME move to the processing of the turn }
private void ProcessTurnAction() { // How we can understand what to do? We may need to keep track if we are playing something // Pick the lower order, if we got only -1 then we are done int min = 10; int index = -1; for (int i = 0; i < turn.order.Length; i++) { if (turn.order[i] < min) { min = turn.order[i]; index = i; } } if (index == -1) // Nothing more to do, reset the status and wait for a new command { ShowMessage("Turn completed, select your next action"); // FIMXE if defeated change the message and just set the action to none and no possible endturn wtf = WhatTheFuckStatus.GetLost; DisableButtons.gameObject.SetActive(false); EndTurnButton.enabled = true; HideAllViews(); engine.mySelf.action = ActionType.Nothing; GD.DebugLog("Next turn completed", GD.LT.Debug); Highlighter.SetActive(false); return; } // Set the resources for the player Player player = engine.players[index]; // FIXME engine.UpdateResources(player); <-- we may need to get the new resources from the net Highlighter.SetActive(true); Highlighter.transform.localPosition = new Vector3(206 * index, 0, 0); // Show something depending on the action, we may have the result of the action inside the turn FIXME it is not yet available switch (player.action) { case ActionType.Nothing: ShowMessage(player.def.name + " does nothing"); break; case ActionType.FindResources: // We cannot really see the extra resources ShowMessage(player.def.name + " is finding resources.\nFound extra FIXME"); // Show stuff for other players only if we have counterintelligence break; case ActionType.ResearchTechnology: // FIXME show details only if we have intelligence ShowMessage(player.def.name + " researched technology " + GD.GetTechName(player.val1)); engine.players[index].techs[player.val1] = true; GameObject visualTech = Instantiate(TechPrefab, CityTemplate.transform.parent); visualTech.transform.position = GetCenterSector(player); break; case ActionType.BuildImprovement: // FIXME show details only if we have intelligence // Do we still have this city? if (!player.cities.Contains(player.val1)) { ShowMessage(player.def.name + " tried to build " + GD.GetImprovementName(player.val2) + " on city #" + player.val1 + " but the city does not belong anymore to " + player.def.name); } else if (engine.cityVals[player.val1].status == CityStatus.Destroyed) { ShowMessage(player.def.name + " tried to build " + GD.GetImprovementName(player.val2) + " on city #" + player.val1 + " but the city is destroyed."); } else { ShowMessage(player.def.name + " is building " + GD.GetImprovementName(player.val2) + " on city #" + player.val1); engine.cityVals[player.val1].SetImprovement(player.val2); } GameObject visualBuild = Instantiate(BuildPrefab, CityTemplate.transform.parent); visualBuild.transform.position = GetCenterCity(player.val1); break; case ActionType.Social: ShowMessage(player.def.name + " is promoting social activities"); // List all cities, sorted by population size. Have a person go from the first to the last. When completed exchange population. ExecuteSocialActivities(player); break; default: ShowMessage(player.def.name + " unhandled action " + player.action.ToString(), true); break; } timeToWait = waitTime; turn.order[index] = 255; }