//UI update Methods public void Intel_UI_update(GameObject Object) { //Find object type and display according to switch (WhatKindOfObjectIsThisOne(Object)) { case TokenType.Default: Debug.Log("Object Type cannot be defined"); break; case TokenType.Unit: Unit_script UnitValues = Object.GetComponent <Unit_script>(); //Display Image_icon.material = Resources.Load <Material>("Textures/UI_" + UnitValues.type); TYPE_text.text = UnitValues.type.ToString(); HV_text.text = UnitValues.health.ToString(); HL_text.text = UnitValues.H_limit.ToString(); AV_text.text = UnitValues.ammo.ToString(); AL_text.text = UnitValues.A_limit.ToString(); MV_text.text = UnitValues.mvt.ToString(); ML_text.text = UnitValues.M_limit.ToString(); Player_text.text = "P" + UnitValues.Owner.ToString(); break; case TokenType.Building: Batiment_script BuildingValues = Object.GetComponent <Batiment_script>(); //Display Image_icon.material = Resources.Load <Material>("Textures/UI_" + BuildingValues.type); TYPE_text.text = BuildingValues.type.ToString(); HV_text.text = ""; HL_text.text = ""; AV_text.text = ""; AL_text.text = ""; MV_text.text = ""; ML_text.text = ""; Player_text.text = ""; break; case TokenType.Case: Case_script CaseValues = Object.GetComponent <Case_script>(); //Display Image_icon.material = Resources.Load <Material>("Textures/UI_" + CaseValues.Terrain.name); TYPE_text.text = CaseValues.Terrain.name.ToString(); HV_text.text = "N/A"; HL_text.text = "N/A"; AV_text.text = "N/A"; AL_text.text = "N/A"; MV_text.text = "N/A"; ML_text.text = "N/A"; Player_text.text = CaseValues.Occupation.ToString(); break; } }
public void Move_A_UI_update(GameObject Object) { Unit_script UnitValues = Object.GetComponent <Unit_script>(); Voyager_icon.material = Resources.Load <Material>("Textures/UI_" + UnitValues.type); Voyager_HV.text = UnitValues.health.ToString(); Voyager_HL.text = UnitValues.H_limit.ToString(); Voyager_AV.text = UnitValues.ammo.ToString(); Voyager_AL.text = UnitValues.A_limit.ToString(); Voyager_MV.text = UnitValues.mvt.ToString(); Voyager_ML.text = UnitValues.M_limit.ToString(); Voyager_Player.text = UnitValues.Owner.ToString(); UI_values.Step = UI_Manager_script.StepType.DefineDestination; ElementA = Object; }
private void OnMouseUp() { //Phase 1 Step Case selection for unit if (UI_values.Phase_number == 1 && UI_values.Step == UI_Manager_script.StepType.Token_creation_case) { //Check if case is free if (Occupation == OccupationType.Free) { //Check if valid building is near if (true /*HasCaseAnAdjacentAllyBuilding()*/) { //Send Case adress to GameManager (HUD1) HUD1Value.Unit_Deployment(this.gameObject); } } } //Phase 2 Step Intel if (UI_values.Phase_number == 2 && UI_values.Step == UI_Manager_script.StepType.Intel) { HUD2Value.Intel_UI_update(this.gameObject); } //Phase 2 Step Move B if (UI_values.Phase_number == 2 && UI_values.Step == UI_Manager_script.StepType.DefineDestination) { if (Occupation == OccupationType.Free) //Case must be free { GameObject Voyager = HUD2Value.ElementA; Unit_script Voyager_values = Voyager.GetComponent <Unit_script>(); //Debug.Log(Voyager.name); Case_script Origin_Case = Voyager_values.Occupied_case.GetComponent <Case_script>(); if (CheckVoisine(Origin_Case)) //Case must be adjacente { HUD2Value.Move_B_UI_update(this.gameObject); } else { Debug.Log("This case is not a good choice"); } } else { Debug.Log("Destination is not free"); } } }
public void Attack_B_UI_update(GameObject Object) { if (ElementA != Object && UI_values.Step == UI_Manager_script.StepType.DefineAttacked) { //Find object type and display according to switch (WhatKindOfObjectIsThisOne(Object)) { case TokenType.Default: Debug.Log("Object Type cannot be defined"); break; case TokenType.Unit: Unit_script UnitValues = Object.GetComponent <Unit_script>(); //Display Attacked_icon.material = Resources.Load <Material>("Textures/UI_" + UnitValues.type); Attacked_HV.text = UnitValues.health.ToString(); Attacked_HL.text = UnitValues.H_limit.ToString(); Attacked_AV.text = UnitValues.ammo.ToString(); Attacked_AL.text = UnitValues.A_limit.ToString(); Attacked_MV.text = UnitValues.mvt.ToString(); Attacked_ML.text = UnitValues.M_limit.ToString(); Attacked_Player.text = UnitValues.Owner.ToString(); break; case TokenType.Building: Batiment_script BuildingValues = Object.GetComponent <Batiment_script>(); //Display Attacked_icon.material = Resources.Load <Material>("Textures/UI_" + BuildingValues.type); Attacked_HV.text = BuildingValues.health.ToString(); Attacked_HL.text = BuildingValues.H_limit.ToString(); Attacked_AV.text = BuildingValues.ammo.ToString(); Attacked_AL.text = BuildingValues.A_limit.ToString(); Attacked_MV.text = "N/A"; Attacked_ML.text = "N/A"; Attacked_Player.text = BuildingValues.Owner.ToString(); break; case TokenType.Case: Debug.Log("Case cannot be attacked / No function available"); break; } UI_values.Step = UI_Manager_script.StepType.ReadyAttack; ElementB = Object; } }
public void Unit_Deployment(GameObject Deployment_Case) { if (IsThisTerrainAcceptableForSuchUnit(Deployment_Case)) { //GameObject Selected_case => Case_script Case_script Deployment_zone = Deployment_Case.GetComponent <Case_script>(); //Unit_creation GameObject NewUnit = (GameObject)Instantiate(UnitPrefab); Unit_script NewUnitValue = NewUnit.GetComponent <Unit_script>(); //Unit Set_up //GameObject NewUnit.name = "UNIT_" + UnitDeployed; NewUnit.transform.position = Deployment_Case.transform.position + new Vector3(0, 0.2f, 0); //Unit values NewUnitValue.Owner = UI_values.Player_turn; NewUnitValue.Occupied_case = Deployment_zone; NewUnitValue.Set_up_unit_values(Unit_To_Be_Deployed); //Color NewUnitValue.Change_Color(); //Case update Deployment_zone.OccupingUnit = NewUnitValue; Deployment_zone.Occupation = Case_script.OccupationType.Unit; //Player Update //Ressources Ressources_Payment(Unit_To_Be_Deployed); //Miscellaneous UnitDeployed++; UI_values.Step = UI_Manager_script.StepType.none; Intel.text = "P" + UI_values.Player_turn + " created " + Unit_To_Be_Deployed; } else { Intel.text = "Terrain not suitable for " + Unit_To_Be_Deployed.ToString(); } }
public void SD_Perform(int a) { if (UI_values.Step == UI_Manager_script.StepType.ReadySelfDestruct) { //Random function float random_value = 0f; //Success value float success_value = 0f; GameObject SDer = ElementA; if (random_value >= success_value) { switch (WhatKindOfObjectIsThisOne(ElementA)) { case TokenType.Default: Debug.Log("Object Type cannot be defined"); break; case TokenType.Unit: Unit_script Unit_values = SDer.GetComponent <Unit_script>(); //Success? => loose health Unit_values.Change_Health_stock(-10f); break; case TokenType.Building: Batiment_script Building_values = SDer.GetComponent <Batiment_script>(); //Success? => loose health Building_values.Change_Health_stock(-10f); break; case TokenType.Case: Debug.Log("Case cannot Self-destruct / No function available"); break; } } SD_cancel(1); } }
public void Move_Perform(int a) { if (UI_values.Step == UI_Manager_script.StepType.ReadyMove) { GameObject Voyager = ElementA; Unit_script Voyager_values = Voyager.GetComponent <Unit_script>(); Case_script Origin_Case = Voyager_values.Occupied_case.GetComponent <Case_script>(); GameObject destination = ElementB; Case_script destination_values = destination.GetComponent <Case_script>(); //Remplace l'occupation de la case occupée avant le mouvement par l'unité Origin_Case.Occupation = Case_script.OccupationType.Free; //Le token unité bouge à son nouvel emplacement Voyager.transform.position = destination.transform.position + new Vector3(0, 0.2f, 0); Voyager_values.Occupied_case = destination_values; //La case destination est occupée destination_values.Occupation = Case_script.OccupationType.Unit; destination_values.Owning_control = Voyager_values.Owner; //L'unité perd un mouvement Voyager_values.Change_Mvt_stock(-1f); Move_Cancel(1); } }
public void Attack_Perform(int a) { if (UI_values.Step == UI_Manager_script.StepType.ReadyAttack) { //Random function float random_value = 0f; //Success value float success_value = 0f; GameObject Attacker = ElementA; GameObject Attacked = ElementB; //Attacker loses 1 ammo switch (WhatKindOfObjectIsThisOne(ElementA)) { case TokenType.Default: Debug.Log("ElementA Type cannot be defined"); break; case TokenType.Unit: Unit_script UnitValues = ElementA.GetComponent <Unit_script>(); //Call function reducing ammo UnitValues.Change_Ammo_stock(-1f); break; case TokenType.Building: Batiment_script BuildingValues = ElementA.GetComponent <Batiment_script>(); //Call function reducing ammo BuildingValues.Change_Ammo_stock(-1f); break; case TokenType.Case: Debug.Log("Case cannot attack / No function available"); break; } //Attacked might loses 1 health if (random_value >= success_value) { switch (WhatKindOfObjectIsThisOne(ElementB)) { case TokenType.Default: Debug.Log("Object Type cannot be defined"); break; case TokenType.Unit: Unit_script UnitValues = ElementB.GetComponent <Unit_script>(); //Call function reducing ammo UnitValues.Change_Health_stock(-1f); break; case TokenType.Building: Batiment_script BuildingValues = ElementA.GetComponent <Batiment_script>(); //Call function reducing ammo BuildingValues.Change_Health_stock(-1f); break; case TokenType.Case: Debug.Log("Case cannot be attacked / No function available"); break; } } Attack_cancel(1); } }