public static string GetOutPackagePath(bool withFileHead = true) { string path = ""; if (Random.Range(0, 1) == 1) { if (IsEditor()) { path = "file://" + Application.dataPath + "/../DownloadData/"; } else if (Application.platform == RuntimePlatform.WindowsPlayer) { path = "file://" + Application.persistentDataPath + "/"; path = GameUtilities.ConvertNativeUrlToWindowsPlatform(path); } else if (Application.platform == RuntimePlatform.Android) { path = withFileHead ? "file://" + Application.persistentDataPath + "/" : Application.persistentDataPath + "/"; } else if (Application.platform == RuntimePlatform.IPhonePlayer) { path = "file://" + Application.persistentDataPath + "/"; } } else { path = GetStreamingAssetbuddleResourcePath(); } return(path); }
public void loadLvlUpSkills(List <string> mSkills, List <string> newSkills) { List <SkillMeta> Skills = new List <SkillMeta>(GameUtilities.parseSkills(newSkills.ToArray(), PanelManager.instance.glossaryObj.GetComponent <Glossary>())); for (int i = 0; i < 4; i++) { if (newSkills.Count > i) { GameObject.Find("LSk0" + (i + 1) + "C").GetComponent <Text>().text = mSkills.Contains(newSkills[i]) ? newSkills[i] : "<color=#0000ff>" + newSkills[i] + "</color>"; GameObject.Find("LSk0" + (i + 1) + "D").GetComponent <Text>().text = PanelManager.getEffectsString(Skills[i].effects); } else { GameObject.Find("LSk0" + (i + 1) + "C").GetComponent <Text>().text = ""; GameObject.Find("LSk0" + (i + 1) + "D").GetComponent <Text>().text = ""; } } if (newSkills.Count > 4) { GameObject.Find("LSk05C").GetComponent <Text>().text = "<color=#0000ff>" + newSkills[4] + "</color>"; GameObject.Find("LSk05D").GetComponent <Text>().text = PanelManager.getEffectsString(Skills[4].effects); } else { GameObject.Find("LSk05C").GetComponent <Text>().text = ""; GameObject.Find("LSk05D").GetComponent <Text>().text = ""; } }
protected override void OnDisable() { base.OnDisable(); if (setFocusOnEnable) { if (useStairFocus) { FocusManager.DownLayer(); } else { FocusManager.ChangeLayer(_oldLayerFocus); } if (storageFocusedObject) { FocusManager.RestoreFocusSaved(); } } FocusManager.OnChangeLayer -= OnChangeLayer; GameUtilities.StopTimer <LayerFocus>(OnChangeLayer); }
public IEnumerator waitHint() { yield return(new WaitForSeconds(20f)); if (!GameManager.instance.gameOver) { List <coords> validMoves = new List <coords>(); int[,] tempBoard = new int[xSize, ySize]; for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { tempBoard[x, y] = (int)tiles[x, y].GetComponent <Tile>().type.type; tiles[x, y].GetComponent <Tile>().Deselect(); } } List <Vector2> positions = new List <Vector2>(); int[,] scoreBoard = new int[xSize, ySize]; for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { foreach (Vector2 dir in Tile.adjacentDirections) { int[,] copyBoard = tempBoard.Clone() as int[, ]; if (dir.x + x >= 0 && dir.x + x < xSize && dir.y + y >= 0 && dir.y + y < ySize) { int temp = copyBoard[(int)dir.x + x, (int)dir.y + y]; copyBoard[(int)dir.x + x, (int)dir.y + y] = copyBoard[x, y]; copyBoard[x, y] = temp; // At the two points selected, look out in all the directions and see if we've found a match int mtchA = returnBoardMatches(copyBoard, new Vector2(x, y)); int mtchB = returnBoardMatches(copyBoard, new Vector2((int)dir.x + x, (int)dir.y + y)); int score = mtchA > mtchB ? mtchA : mtchB; scoreBoard[x, y] = score; if (score > 2) { positions.Add(new Vector2(x, y)); validMoves.Add(new coords(tiles[x, y].GetComponent <Tile>(), dir)); } } } } } coords[] moves = validMoves.ToArray(); GameUtilities.ShuffleArray(moves); if (moves[0].tile.GetAdjacent(moves[0].dir) != null) { moves[0].tile.SelectHint(); moves[0].tile.GetAdjacent(moves[0].dir).GetComponent <Tile>().SelectHint(); } } }
static void Main(string[] args) { Console.Title = "Battleship by Robbie Nielsen"; Game game = new Game(); GameUtilities utilities = new GameUtilities(); utilities.PrintBattleshipLogo(); utilities.PrintIntro(); Console.ReadKey(true); utilities.PrintCoinFlip(); Thread.Sleep(1000); string player1 = game.EnterPlayerName("1"); string player2 = game.EnterPlayerName("2"); utilities.ConfirmPlayerNamesPrompt(player1, player2); string confirmNames = Console.ReadLine(); bool namesConfirmed = Validator.AreNamesConfirmed(confirmNames); while (!namesConfirmed) { Console.Clear(); utilities.PrintBattleshipLogo(); player1 = game.EnterPlayerName("1"); player2 = game.EnterPlayerName("2"); utilities.ConfirmPlayerNamesPrompt(player1, player2); confirmNames = Console.ReadLine(); namesConfirmed = Validator.AreNamesConfirmed(confirmNames); } Console.WriteLine("Starting game..."); game.Player1 = new Player(player1); game.Player2 = new Player(player2); Thread.Sleep(1500); Console.Clear(); game.SetShips(game.Player1, game.Player2); Console.WriteLine(player1 + "'s ships are all placed! Press any key to place " + player2 + "'s ships..."); Console.ReadKey(true); Console.Clear(); game.SetShips(game.Player2, game.Player1); Console.WriteLine("All ships placed! Press any key when ready..."); Console.ReadKey(true); game.Play(); Thread.Sleep(1000); Console.WriteLine("Goodbye! Press any key to exit..."); Console.ReadKey(); }
void Awake() { groundLayerNum = GameUtilities.GetLayerNumber(groundLayer); _health = GetComponent <Health>(); _score = GetComponent <Score>(); _animator = GetComponent <Animator>(); }
public void PopulateShop() { shopActive = true; Debug.Log("PopulateShop"); Glossary glossy = PauseManager.instance.glossaryObj.GetComponent <Glossary>(); List <string> defeated = GameUtilities.getInteractedWith(glossy, false, true); if (defeated.Contains("Gaia Temple Leader Audrey") && !shopOwnersStock.ContainsKey("Stim")) { shopOwnersStock.Add("Stim", 150); } if (shopitemSubPnls == null) { shopitemSubPnls = new GameObject[] { GameObject.Find("ShopItemPnl01"), GameObject.Find("ShopItemPnl02"), GameObject.Find("ShopItemPnl03"), GameObject.Find("ShopItemPnl04"), GameObject.Find("ShopItemPnl05"), GameObject.Find("ShopItemPnl06"), GameObject.Find("ShopItemPnl07"), GameObject.Find("ShopItemPnl08"), GameObject.Find("ShopItemPnl09") }; } AdventureMeta meta = BaseSaver.getAdventure(); Dictionary <string, int> treasure = meta.GetTreasureList(); List <string> inventoryKeys = new List <string>(treasure.Keys); List <string> shopKeys = new List <string>(shopOwnersStock.Keys); GameObject.Find("MoneyTxt").GetComponent <Text>().text = "¥" + meta.getYen(); for (int i = 1; i < 10; i++) { if (shopKeys.Count >= i) { shopitemSubPnls[i - 1].SetActive(true); string img = "SI0" + i.ToString() + "Img"; string nme = "SI0" + i.ToString() + "Name"; string description = "SI0" + i.ToString() + "Desc"; string qty = "SI0" + i.ToString() + "Qty"; string cost = "SI0" + i.ToString() + "Cost"; GameObject.Find(img).GetComponent <Image>().sprite = glossy.GetItem(shopKeys[i - 1]).GetComponent <SpriteRenderer>().sprite; GameObject.Find(nme).GetComponent <Text>().text = shopKeys[i - 1]; GameObject.Find(description).GetComponent <Text>().text = glossy.GetItem(shopKeys[i - 1]).monTreas.description; GameObject.Find(qty).GetComponent <Text>().text = treasure.ContainsKey(shopKeys[i - 1]) ? treasure[shopKeys[i - 1]].ToString() : "0"; GameObject.Find(cost).GetComponent <Text>().text = "¥" + shopOwnersStock[shopKeys[i - 1]].ToString(); } else { shopitemSubPnls[i - 1].SetActive(false); } } }
public override void Stop() { if (seeker) { seeker.OnFinishSeek -= PreNextWayPoint; seeker.Stop(); GameUtilities.StopTimer(NextWayPoint); } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.DarkGray); DrawGameObjects(); GameUtilities.SetGraphicsDeviceFor3D(); base.Draw(gameTime); }
void Start() { inventory = GetComponent <Inventory>(); if (!inventory) { Debug.LogWarning("WARNING: No inventory to store things!"); } utility = Camera.main.GetComponent <GameUtilities>(); attMovement = GetComponent <AttackMovement>(); }
/// <summary> /// Only difference here is the addition of a condition that checks if the checkbox in the IEmod options is disabled /// before adding the effect to the list /// </summary> public void ApplyEquipFXNew(Transform t, List <GameObject> fx_list) { if (this.m_mod.OnEquipVisualEffect != null && !IEModOptions.HideWeaponEffects) //Added comparison here { GameObject gameObject = GameUtilities.LaunchLoopingEffect(this.m_mod.OnEquipVisualEffect, 1f, t, null); if (gameObject != null && fx_list != null) { fx_list.Add(gameObject); } } }
public void UpdateTempleList(string name) { string temple = GameUtilities.GetTempleFromTrainer(name); if (temple.Length > 0) { List <string> tmp = new List <string>(temples); tmp.Add(temple); temples = tmp.ToArray(); } }
private void OnEnable() { rb = GetComponent <Rigidbody>(); rend = GetComponent <SpriteRenderer>(); utility = Camera.main.GetComponent <GameUtilities>(); direction = Vector3.left; inventory = GetComponent <EnemyInventory>(); move = StartCoroutine(AquamentusMovement()); anim = StartCoroutine(AquamentusAnimation()); dieAction = Die; inventory.RegisterDeathCallbacks(dieAction); }
// Use this for initialization void OnEnable() { rend = GetComponent <SpriteRenderer>(); rb = GetComponent <Rigidbody>(); inventory = GetComponent <EnemyInventory>(); StartCoroutine(KeeseSpeedUp()); StartCoroutine(ChangeDirection()); StartCoroutine(KeeseAnimation()); utility = Camera.main.GetComponent <GameUtilities>(); dieAction = Die; inventory.RegisterDeathCallbacks(dieAction); }
private void PushPathBlockedStateNew(List <Mover> obstacles, bool forceBlock) { if (this.AIController != null && !Cutscene.CutsceneActive) { if (!forceBlock && !this.AIController.StateManager.CurrentState.AllowBlockedMovement()) { return; } this.SaveBlockedRoute(); this.m_desiredHeading = GameUtilities.V3Subtract2D(this.m_nextCornerPos, base.transform.position); this.m_desiredHeading.Normalize(); this.m_heading = this.m_desiredHeading; if (this.AIController is PartyMemberAI) { if (this.AIController.StateManager.CurrentState is AI.Player.WaitForClearPath) { return; } AI.Player.WaitForClearPath waitForClearPath = AIStateManager.StatePool.Allocate <AI.Player.WaitForClearPath>(); waitForClearPath.Obstacles.AddRange(obstacles); waitForClearPath.BlockerDistance = 0.5f; this.AIController.StateManager.PushState(waitForClearPath, false); } else { if (this.AIController.StateManager.CurrentState is AI.Plan.WaitForClearPath) { return; } if (IEModOptions.ImprovedAI) // added this if statement { // race condition if both Mover and PathFindingManager decide they are blocked in the same tick if (this.AIController.StateManager.CurrentState is AI.Plan.ApproachTarget) { return; } var pathToPosition = this.AIController.StateManager.CurrentState as AI.Achievement.PathToPosition; if (pathToPosition != null) { if (((Mod_AI_PathToPosition)pathToPosition).TryToPickNewTarget(true)) { return; } } } AI.Plan.WaitForClearPath waitForClearPath2 = AIStateManager.StatePool.Allocate <AI.Plan.WaitForClearPath>(); waitForClearPath2.Obstacles.AddRange(obstacles); waitForClearPath2.BlockerDistance = 0.5f; this.AIController.StateManager.PushState(waitForClearPath2, false); } } }
// Update is called once per frame void Update() { if (IsDead()) { EnemyIDMsg msg = new EnemyIDMsg(EnemyID, EType); GameUtilities.Broadcast("DestroyThisEnemy", msg); } PassiveUpdatePlayerAggro(); AttackMaxAggroPlayer(); //LookAtTestPlayer(); }
void Update() { if (Input.GetKeyDown(KeyCode.Semicolon)) { DamageTankMsg msg = new DamageTankMsg(0, CurrentFrame, 20.0f); GameUtilities.Broadcast("DamageTank", msg); } if (health <= 0.0f) { FailLevel(); } }
void CheckStrafeTank() { if (Input.GetKey(StrafeLeft)) { TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, true); GameUtilities.Broadcast("StrafeTank", msg); } if (Input.GetKey(StrafeRight)) { TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, false); GameUtilities.Broadcast("StrafeTank", msg); } }
void CreateSingleton() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private void PreNextWayPoint() { float time = _nextWaypont.waitAtWaypoint; if (time != 0) { GameUtilities.WaitForMethod(time, NextWayPoint); } else { NextWayPoint(); } }
void CheckMoveTank() { if (Input.GetKey(Forward)) { //forward TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, true); GameUtilities.Broadcast("MoveTank", msg); } if (Input.GetKey(Backward)) { //backward TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, false); GameUtilities.Broadcast("MoveTank", msg); } }
void OnEnable() { // TODO: Wallmaster sounds for when you enter/exit the room utility = Camera.main.GetComponent <GameUtilities>(); rend = GetComponent <SpriteRenderer>(); rb = GetComponent <Rigidbody>(); player = GameObject.Find("Player"); playerAttacked = player.GetComponent <BeingAttacked>(); inventory = GetComponent <EnemyInventory>(); cam = Camera.main; dieAction = Die; inventory.RegisterDeathCallbacks(dieAction); }
IEnumerator checkItemPickedUp() { bool pickedUp = GameUtilities.getPickedUp(BaseSaver.getMap(), transform.position); //Debug.Log("Item: " + name); //Debug.Log("Picked Up: " + pickedUp.ToString()); if (pickedUp) { //Destroy(this.gameObject); this.gameObject.SetActive(false); } yield return(null); }
private Vector3 GetMarkerPositionBySlotNew(int slot, bool secondary) { if (PartyInteractionPointsIsNull() || slot < 0) { return(base.transform.position); } if (slot >= 5) { if (PartyInteractionPoints.Length - 1 < slot) { Array.Resize(ref PartyInteractionPoints, slot + 1); } if (PartyInteractionPoints[slot] == null) { PartyInteractionPoints[slot] = new GameObject().transform; } else { return(PartyInteractionPoints[slot].transform.position); } var neighbor = PartyInteractionPoints[slot - 1] ?? PartyInteractionPoints[0]; var position = neighbor.transform.position + Vector3.right; var rotation = neighbor.transform.rotation; PartyInteractionPoints[slot].transform.SetPositionAndRotation(position, rotation); } if (slot >= PartyInteractionPoints.Length) { return(base.transform.position); } if (secondary) { Vector3 hitPosition = PartyInteractionPoints[slot].position + PartyInteractionPoints[slot].right; Vector3 origin = hitPosition + Vector3.up * 2f; RaycastHit result; if (GameUtilities.Raycast(origin, Vector3.down, out result, float.PositiveInfinity, LayerUtility.WalkableLayersMask)) { hitPosition = result.point; } NavMeshUtility.SamplePosition(hitPosition, out hitPosition, 5f, NavMeshUtility.WalkableAreasMask); return(hitPosition); } return(PartyInteractionPoints[slot].position); }
// Use this for initialization void Start() { if (Instance != null) { Debug.LogError("Multiple instances of GameUtilities!"); } else { Instance = this; tickTimeLeft = tickTime; textMoney.text = money.ToString(); textResearch.text = research.ToString(); } }
// Update is called once per frame void Update() { if (state == GameState.None) { //user has clicked or touched if (Input.GetMouseButtonDown(0)) { //get the hit position var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) //we have a hit!!! { hitGo = hit.collider.gameObject; state = GameState.SelectionStarted; } } } else if (state == GameState.SelectionStarted) { //user dragged if (Input.GetMouseButton(0)) { var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); //we have a hit if (hit.collider != null && hitGo != hit.collider.gameObject) { //user did a hit, no need to show him hints StopCheckForPotentialMatches(); //if the two shapes are diagonally aligned (different row and column), just return if (!GameUtilities.AreVerticalOrHorizontalNeighbors(hitGo.GetComponent<Shape>(), hit.collider.gameObject.GetComponent<Shape>())) { state = GameState.None; } else { state = GameState.Animating; FixSortingLayer(hitGo, hit.collider.gameObject); StartCoroutine(FindMatchesAndCollapse(hit)); } } } } }
private Vector3 GetMarkerPositionBySlotNew(int slot, bool secondary) { if (WaypointsIsNull() || slot < 0) { return(base.transform.position); } if (slot >= 5) { if (Waypoints.Length - 1 < slot) { Array.Resize(ref Waypoints, slot + 1); } if (Waypoints[slot] == null) { Waypoints[slot] = new GameObject(); } else { return(Waypoints[slot].transform.position); } var neighbor = Waypoints[slot - 1] ?? Waypoints[0]; var position = neighbor.transform.position + Vector3.right; var rotation = neighbor.transform.rotation; Waypoints[slot].transform.SetPositionAndRotation(position, rotation); } if (slot >= Waypoints.Length) { return(base.transform.position); } if (secondary) { Vector3 vector = Waypoints[slot].transform.position + Waypoints[slot].transform.right; Vector3 origin = vector + Vector3.up * 2f; RaycastHit result; if (GameUtilities.Raycast(origin, Vector3.down, out result, float.PositiveInfinity, -5)) { vector = result.point; } return(vector); } return(Waypoints[slot].transform.position); }
private void Awake() { //Ensure that an instance of the GameUtilities class does not already exist if (instance == null) { //Set this class as the instance and ensure that it stays when changing scenes instance = this; DontDestroyOnLoad(gameObject); } //If there is an existing instance that is not this, destroy the GameObject this script is connected to else if (instance != this) { Destroy(gameObject); } }
// Use this for initialization void Start() { playerObject = GameObject.FindGameObjectWithTag("Player"); //find player. hopefully nothing else gets the "Player" tag collectableObject = gameObject; //get collectable game object if (playerObject != null) { playerCollider = playerObject.GetComponent <Collider>(); //get collider for intersection detection } if (collectableObject != null) { collectableCollider = collectableObject.GetComponent <Collider>(); //get collider for intersection detection } GameUtilities.FindGame(ref OwningGame); }
void CheckTurnTank() { if (Input.GetKey(Left)) { TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, false); GameUtilities.Broadcast("TurnTank", msg); MarkSyncNeeded(); } if (Input.GetKey(Right)) { TankComponentMovementMsg msg = new TankComponentMovementMsg(TankID, CurrentFrame, true); GameUtilities.Broadcast("TurnTank", msg); MarkSyncNeeded(); } }