/// <summary> /// Handle input for focus on spawnUnit. /// </summary> /// <param name="ctx">CallBackContext of input</param> /// <param name="spawnUnitTag">tag of the spawnUnit to focus</param> private void FocusCameraOnSpawnUnit(InputAction.CallbackContext ctx, string spawnUnitTag) { if (ECamState.Iso2D == m_cameraState) { return; } SpawnUnits spawnToFocus = GameManager.Instance.GetSpawnUnitForPlayer(GameManager.Instance.GetLocalPlayer(), spawnUnitTag); spawnToFocus.ShowUISpawnUnit(); spawnToFocus.GetComponent <ObjectSelection>().OnMouseDown(); double timer; if (spawnUnitTag == Constant.ListOfTag.s_spawnUnit1) { timer = m_timerDoubleTapSpawn1; m_timerDoubleTapSpawn1 = ctx.time; m_timerDoubleTapSpawn2 = 0; } else { timer = m_timerDoubleTapSpawn2; m_timerDoubleTapSpawn2 = ctx.time; m_timerDoubleTapSpawn1 = 0; } if (ctx.time > timer + m_timerDoubleTap) { return; } StartCoroutine(MoveCameraToPosition(spawnToFocus.gameObject.transform.position)); }
public IEnumerator Start() { yield return(new WaitUntil(() => GameManager.Instance != null)); yield return(new WaitUntil(GameManager.Instance.GetAllPlayersReady)); if (NetworkServer.connections.Count == 1 && m_playerNumber == PlayerEntity.Player.Player2) { yield return(new WaitWhile(() => null == FindObjectOfType <AIControl>())); m_playerNumber = PlayerEntity.Player.Bot; m_player = FindObjectOfType <AIControl>(); yield return(new WaitUntil(() => NetworkServer.SpawnWithClientAuthority(m_player.gameObject, GameManager.Instance.GetPlayer(PlayerEntity.Player.Player1).GetComponent <NetworkIdentity>().connectionToClient))); } else { m_player = NetworkServer.connections[(int)m_playerNumber].playerControllers[0].gameObject.GetComponent <PlayerEntity>(); } m_player.TakeControl(GetComponent <NetworkIdentity>()); foreach (GameObject item in m_objectToControl) { m_player.TakeControl(item.GetComponent <NetworkIdentity>()); if (item.GetComponent <SpawnUnits>()) { SpawnUnits spawnUnits = item.GetComponent <SpawnUnits>(); spawnUnits.RpcInitPlayerNumber(m_playerNumber); spawnUnits.SetTarget(GetNearestNexus().gameObject); } } }
public override void SetPlayerOwner(PlayerEntity.Player player) { base.SetPlayerOwner(player); SpawnUnits spawnUnitsComponent = GetComponent <SpawnUnits>(); spawnUnitsComponent.SetPlayerNumber(m_playerOwner); spawnUnitsComponent.SetTarget(GetNearestEnemyNexus().gameObject); spawnUnitsComponent.GetUISelectSpawnUnit().SetIcons(); }
/// <summary> /// Set the spawnUnit so unit spawn from the selected one /// </summary> /// <param name="selectedSpawnUnit">spawnUnit to spawn</param> public void SetupUI(SpawnUnits selectedSpawnUnit) { foreach (UISpawnUnitButton button in m_buttons) { if (CameraManager.Instance.GetCameraState() == CameraManager.ECamState.Ortho3D) { StartCoroutine(fadeButton(button.gameObject.GetComponent <Button>(), true, 1)); } button.SetSpawnUnit(selectedSpawnUnit); } }
public void SetSpawnUnit(SpawnUnits spawnUnit) { m_spawnUnits = spawnUnit; if (GameManager.Instance.GetLocalPlayer() == PlayerEntity.Player.Player1) { m_imageUnit.sprite = m_spriteSyca; } else if (GameManager.Instance.GetLocalPlayer() == PlayerEntity.Player.Player2) { m_imageUnit.sprite = m_spriteArca; } }
// Use this for initialization void Start() { unitSpawner = GameObject.Find("UnitSpawner"); spawnRef = unitSpawner.GetComponent <SpawnUnits>(); combatMenuManager = GameObject.FindGameObjectWithTag("MainBattleUI"); combatMenuRef = combatMenuManager.GetComponent <CombatChoiceManager>(); combatMenuManager.gameObject.SetActive(false); rowRef = 0; columnRef = 0; unitRef = 0; this.transform.SetPositionAndRotation(new Vector3(spawnRef.enemyArray[unitRef].transform.position.x, spawnRef.enemyArray[unitRef].transform.position.y + 1.58f, spawnRef.enemyArray[unitRef].transform.position.z), Quaternion.identity); }
public void SimulationUpdate() { // Spawning SpawnUnits.Apply(CurrentUnits, CurrentData, PreviousData, RandomField, Magic, Output: Temp1); Swap(ref CurrentData, ref Temp1); SetSpawn_Unit.Apply(CurrentUnits, CurrentData, Magic, GameClass.World.PlayerTeamVals, Output: Temp1); Swap(ref CurrentUnits, ref Temp1); SetSpawn_Target.Apply(TargetData, CurrentData, RandomField, Magic, Output: Temp1); Swap(ref TargetData, ref Temp1); SetSpawn_Data.Apply(CurrentUnits, CurrentData, Output: Temp1); Swap(ref CurrentData, ref Temp1); // Corpses AddCorpses.Apply(CurrentUnits, CurrentData, Corpses, Magic, Output: Temp1); Swap(ref Corpses, ref Temp1); // Pathfinding Movement_UpdateDirection_RemoveDead.Apply(TargetData, CurrentUnits, Extra, CurrentData, PreviousData, DistanceToOtherTeams, RandomField, Magic, Geo, AntiGeo, Dirward[Dir.Right], Dirward[Dir.Left], Dirward[Dir.Up], Dirward[Dir.Down], Output: Temp1); Swap(ref CurrentData, ref Temp1); Movement_SetPolarity_Phase1.Apply(CurrentData, Extra, Geo, AntiGeo, Output: Temp1); Swap(ref Extra, ref Temp1); Movement_SetPolarity_Phase2.Apply(CurrentData, Output: Temp1); Swap(ref CurrentData, ref Temp1); // Movement execution Movement_Phase1.Apply(CurrentData, RandomField, Output: Temp1); Movement_Phase2.Apply(CurrentData, Temp1, Output: Temp2); Swap(ref CurrentData, ref PreviousData); Swap(ref Temp2, ref CurrentData); Movement_Convect.Apply(TargetData, CurrentData, Output: Temp1); Swap(ref TargetData, ref Temp1); Movement_Convect.Apply(Extra, CurrentData, Output: Temp1); Swap(ref Extra, ref Temp1); Movement_Convect.Apply(CurrentUnits, CurrentData, Output: Temp1); Swap(ref CurrentUnits, ref Temp1); Swap(ref PreviousUnits, ref Temp1); // Attacking CheckForAttacking.Apply(CurrentUnits, CurrentData, RandomField, Magic, Output: Temp1); Swap(ref CurrentUnits, ref Temp1); }
/// <summary> /// Set spawnunit depending on the localplayer and the ESpawnUnit of this /// </summary> protected virtual IEnumerator SetSpawnUnit() { string tag; if (m_type == ESpawnUnit.Top) { tag = Constant.ListOfTag.s_spawnUnit1; } else { tag = Constant.ListOfTag.s_spawnUnit2; } yield return(new WaitWhile(() => GameManager.Instance.GetSpawnUnitForPlayer(GameManager.Instance.GetLocalPlayer(), tag) == null)); m_spawnUnits = GameManager.Instance.GetSpawnUnitForPlayer(GameManager.Instance.GetLocalPlayer(), tag); m_spawnUnits.SetUISelectSpawnUnit(this); SetIcons(); }
// Use this for initialization void Start() { unitRef = 0; tileHolder = GameObject.Find("TileHolder"); tileInfo = tileHolder.GetComponent <TileInfo>(); currentSide = tileInfo.tileArrayLeft; unitSpawner = GameObject.Find("UnitSpawner"); spawnRef = unitSpawner.GetComponent <SpawnUnits>(); combatManager = GameObject.Find("CombatCoordinator"); combatManagerRef = combatManager.GetComponent <CombatManager>(); combatMenuManager = GameObject.FindGameObjectWithTag("MainBattleUI"); combatMenuRef = combatMenuManager.GetComponent <CombatChoiceManager>(); combatMenuManager.gameObject.SetActive(false); for (int i = 0; i < currentSide.Length; i++) { tileRef = currentSide[i].GetComponent <TileProperties>(); if (tileRef.CurrentUnit == combatManagerRef.attacker) { Debug.Log("Unit Found"); } } }
/// <summary> /// Call on start of SpawnUnit, register all of them to the game manager /// </summary> public void AddSpawnUnitToList(PlayerEntity.Player playerNumber, string tag, SpawnUnits spawnUnit) { m_spawnUnits.Add(new KeyValuePair <PlayerEntity.Player, string>(playerNumber, tag), spawnUnit); }
public void SetSpawnUnit(SpawnUnits spawnUnit) { m_spawnunit = spawnUnit; }
public static void Functions(int index) { switch (index) { case 0: break; case 1: GameInfo(); break; case 2: KillFunctions(); break; case 3: Common.ResurrectAndFullRestore(Common.GetUnitUnderMouse()); break; case 4: Common.Buff(Common.GetUnitUnderMouse(), Storage.buffFavouritesGuids[Main.Settings.actionKeyBuffIndex]); break; case 5: editUnit = Common.GetUnitUnderMouse(); break; case 6: teleportUnit = Common.GetUnitUnderMouse(); if (teleportUnit != null && Strings.ToBool(Main.Settings.toggleAddToLog)) { Common.AddLogEntry(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}", Color.black); } break; case 7: if (Strings.ToBool(settings.toggleSpawnEnemiesFromUnitFavourites)) { try { Vector3 pos = Common.MousePositionLocalMap(); float x = 0.0f; float z = 0.0f; foreach (string guid in SpawnUnits.GetStoredGUIDs) { Vector3 finalPos = new Vector3(pos.x + 1.5f * x, pos.y, pos.z + 1.5f * z); SpawnUnits.UnitSpawner(finalPos, guid); x++; if (x > 10f) { x = 0.0f; z++; } } } catch (Exception e) { modLogger.Log(e.ToString()); } } else if (settings.actionKeySpawnRandomEnemy && Strings.ToBool(settings.toggleActionKeyExperimental)) { try { Common.SpawnHostileUnit(Common.MousePositionLocalMap(), ResourcesLibrary.GetBlueprints <BlueprintUnit>().RandomElement()); } catch (Exception e) { modLogger.Log(e.ToString()); } } else { Common.SpawnHostileUnit(Common.MousePositionLocalMap(), banditsGuids[banidtCrIndex]); } break; case 8: rotateUnit = Common.GetUnitUnderMouse(); if (rotateUnit != null && Strings.ToBool(Main.Settings.toggleAddToLog)) { Common.AddLogEntry( Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}", Color.black); } break; case 9: Common.GetUnitUnderMouse().View.AnimationManager.Execute(animationTypes[animationTypesIndex]); break; case 10: FxHelper.SpawnFxOnPoint(BlueprintRoot.Instance.Cheats.SillyCheatBlood, Common.MousePositionLocalMap()); break; case 11: Common.Charm(Common.GetUnitUnderMouse()); break; case 12: Common.AddToParty(Common.GetUnitUnderMouse()); break; case 13: Common.GetUnitUnderMouse().Descriptor.Recreate = true; break; } }
public static void RenderMenu() { GL.BeginVertical("box"); GL.BeginHorizontal(); GL.Label(RichText.MainCategoryFormat(Strings.GetText("label_ActionKey"))); GL.FlexibleSpace(); MenuTools.AddFavouriteButton("ActionKeyRender"); GL.EndHorizontal(); GL.BeginHorizontal(); MainToggle(); GL.EndHorizontal(); if (settings.toggleEnableActionKey == Storage.isTrueString) { GL.Space(10); GL.BeginHorizontal(); GL.Label(Strings.GetText("label_ActionKey") + ": ", GL.ExpandWidth(false)); MenuTools.SetKeyBinding(ref settings.actionKey); GL.EndHorizontal(); GL.Space(10); GL.BeginHorizontal(); if (GL.Button( MenuTools.TextWithTooltip("label_ActionKeyEnableExperimental", "tooltip_ActionKeyEnableExperimental", $"{settings.toggleActionKeyExperimental}" + " ", ""), GL.ExpandWidth(false))) { if (settings.toggleActionKeyExperimental == Storage.isFalseString) { settings.toggleActionKeyExperimental = Storage.isTrueString; settings.actionKeyIndex = 0; settings.actionKeyKillIndex = 0; } else if (settings.toggleActionKeyExperimental == Storage.isTrueString) { settings.toggleActionKeyExperimental = Storage.isFalseString; settings.actionKeyIndex = 0; settings.actionKeyKillIndex = 0; } } GL.EndHorizontal(); MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("warning_ActionKeyExperimentalMode"))); GL.BeginHorizontal(); if (!Strings.ToBool(settings.toggleActionKeyExperimental)) { settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainArray, 3); } else { settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainExperimentalArray, 3); } GL.EndHorizontal(); GL.Space(10); switch (settings.actionKeyIndex) { case 1: MenuTools.ToggleButton(ref settings.toggleActionKeyLogInfo, "buttonToggle_LogInfoToFile", "tooltip_LogInfoToFile"); MenuTools.ToggleButton(ref settings.toggleActionKeyShowUnitInfoBox, "buttonToggle_ShowUnitInfoBox", "tooltip_ShowUnitInfoBox"); break; case 2: if (Strings.ToBool(settings.toggleActionKeyExperimental)) { GL.Space(10); GL.BeginHorizontal(); settings.actionKeyKillIndex = GL.SelectionGrid(settings.actionKeyKillIndex, experimentalKillArray, 3); GL.EndHorizontal(); } break; case 4: if (!Storage.buffFavourites.Any()) { MenuTools.SingleLineLabel(Strings.GetText("message_NoFavourites")); } else { if (Storage.buffFavouritesLoad == true) { Main.RefreshBuffFavourites(); Storage.buffFavouritesLoad = false; } GL.Space(10); GL.BeginHorizontal(); settings.actionKeyBuffIndex = GL.SelectionGrid(settings.actionKeyBuffIndex, Storage.buffFavouritesNames.ToArray(), 2); GL.EndHorizontal(); } if (Storage.buffFavourites != Storage.buffFavouritesGuids) { Storage.buffFavourites = Storage.buffFavouritesGuids; } break; case 5: if (editUnit != null && editUnit.IsInGame && !editUnit.Descriptor.State.IsFinallyDead) { ActionKeyEditStatsGui(editUnit); } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected")); } break; case 6: if (teleportUnit != null && teleportUnit.IsInGame) { MenuTools.SingleLineLabel(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}"); } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected")); } break; case 7: MenuTools.ToggleButton(ref settings.toggleSpawnEnemiesFromUnitFavourites, "buttonToggle_ActionKeySpawnUnitsFromUnitFavourites", "tooltip_ActionKeySpawnUnitsFromUnitFavourites", nameof(settings.toggleSpawnEnemiesFromUnitFavourites)); if (Strings.ToBool(settings.toggleSpawnEnemiesFromUnitFavourites)) { SpawnUnits.FavouritesMenu(); } if (Strings.ToBool(settings.toggleActionKeyExperimental)) { GL.Space(10); settings.actionKeySpawnRandomEnemy = GL.Toggle(settings.actionKeySpawnRandomEnemy, " " + Strings.GetText("toggle_SpawnRandomEnemy"), GL.ExpandWidth(false)); } if (Strings.ToBool(settings.toggleSpawnEnemiesFromUnitFavourites) && settings.actionKeySpawnRandomEnemy) { MenuTools.SingleLineLabel(RichText.BoldRedFormat(Strings.GetText("warning_SpawnRandomHostileUnit_ActionKeySpawnEnemiesFromUnitFavourites"))); } GL.Space(10); if (!Strings.ToBool(settings.toggleSpawnEnemiesFromUnitFavourites)) { MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("label_SpawnHostileBandits1"))); } else { MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("label_SpawnHostileBandits1")) + " " + Strings.Parenthesis(RichText.BoldRedFormat(Strings.GetText("label_SpawnHostileBandits2")))); } MenuTools.SingleLineLabel(Strings.GetText("label_ChallengeRating") + " " + Strings.Parenthesis(Strings.GetText("misc_Bandit"))); GL.BeginHorizontal(); banidtCrIndex = GL.SelectionGrid(banidtCrIndex, numberArray0t7, 8); GL.EndHorizontal(); break; case 8: if (rotateUnit != null && rotateUnit.IsInGame) { MenuTools.SingleLineLabel(Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}"); } else { MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected")); } break; case 9: if (load) { animationTypes.Clear(); animationTypesNames.Clear(); foreach (var animation in (UnitAnimationType[])Enum.GetValues(typeof(UnitAnimationType))) { animationTypes.Add(animation); animationTypesNames.Add(animation.ToString()); } load = false; } GL.BeginHorizontal(); animationTypesIndex = GL.SelectionGrid(animationTypesIndex, animationTypesNames.ToArray(), 3); GL.EndHorizontal(); break; case 13: MenuTools.SingleLineLabel(Strings.GetText("message_RecreateUnitDescriptor")); break; } } GL.EndVertical(); }
// Use this for initialization void Start() { spawnManager = GameObject.Find("UnitSpawner"); spawnRef = spawnManager.GetComponent <SpawnUnits>(); int a = 0; int arraySize = 0; allyIndex = 0; unitIndex = 0; cardArray = new GameObject[moveOrder.Length]; /*placeholderArray = new GameObject[spawnRef.unitArray.Length]; * //counts the number of allied units in order to define the allyArray size * while (a < 6) * { * while (spawnRef.UnitArray[0, a] == null) * { * a++; * } * arraySize++; * } * allyArray = new GameObject[arraySize]; * a = 0; * int b = 0; * //populates allyArray with each allied unit * while (a < 6) * { * while (spawnRef.UnitArray[0, a] == null) * { * a++; * } * allyArray[b] = spawnRef.UnitArray[0, a]; * b++; * } */ for (int i = 0; i < moveOrder.Length; i++) { cardArray[i] = Instantiate(unitCard); cardArray[i].transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform, false); //cardArray[i].transform.SetPositionAndRotation(new Vector3(152.7f, 290.5f - (110 * i), 0), Quaternion.identity); *This is for fullsize cards cardArray[i].transform.SetPositionAndRotation(new Vector3(103.7f, 310.5f - (70 * i), 0), Quaternion.identity); cardArray[i].transform.localScale -= new Vector3(0.35f, 0.35f, 0); currentCard = cardArray[i]; currentCardManager = currentCard.GetComponent <CardManager>(); currentCardImage = currentCard.GetComponent <Image>(); setImage = currentCard.GetComponentInChildren <ImageSet>(); sideRef = moveOrder[i].GetComponent <UnitInfo>(); currentCardManager.unitRef = sideRef; currentCardManager.SetNameText(sideRef.name); currentCardManager.SetLvlText(sideRef.level.ToString()); //setImage.SetImage(sideRef.sprite); if (sideRef.ally) { currentCardImage.sprite = allyCard; } else { currentCardImage.sprite = enemyCard; } //currentCardImage.sprite = moveOrder[i].GetComponent<SpriteRenderer>().sprite; } }