public virtual IEnumerator LoadRoutine() { yield return(new WaitForEndOfFrame()); possibleMoves = new Vector2[6]; int i = 0; for (float angle = 0; angle < 360; angle += 360f / 6) { possibleMoves[i] = VectorExtensions.FromFacingAngle(angle) * WORLD_SCALE; i++; } GetSingleton <SaveAndLoadManager>().Setup(); if (!HasPlayedBefore) { GetSingleton <SaveAndLoadManager>().DeleteAll(); HasPlayedBefore = true; GetSingleton <SaveAndLoadManager>().OnLoaded(); } else { GetSingleton <SaveAndLoadManager>().LoadMostRecent(); } // GetSingleton<AdsManager>().ShowAd (); Init(); yield break; }
public virtual void Do() { points = new Vector2[pointCount]; for (int i = 0; i < pointCount; i++) { points[i] = circle.center + VectorExtensions.FromFacingAngle((i * 360f / pointCount) * (1f / 360f) * 360) * circle.radius; } polygonCollider.points = points; }
public bool Contains(Angle angle, bool equalAnglesIntersect = true) { if (equalAnglesIntersect) { return(Mathf.Abs(Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(min.degrees)) - Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(max.degrees))) <= Degrees); } else { return(Mathf.Abs(Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(min.degrees)) - Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(max.degrees))) < Degrees); } }
public override bool Contains(Angle angle, bool includeMinAndMax = true) { if (includeMinAndMax) { return(Mathf.Abs(Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(min.degrees)) - Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(max.degrees))) <= Degrees); } else { return(Mathf.Abs(Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(min.degrees)) - Vector2.Angle(VectorExtensions.FromFacingAngle(angle.degrees), VectorExtensions.FromFacingAngle(max.degrees))) < Degrees); } }
public override Weapon[] Split(Weapon bullet, Vector2 direction, Weapon splitBulletPrefab, float positionOffset = 0) { Weapon[] output = new Weapon[0]; float toPlayer = (HumanPlayer.Instance.body.trs.position - bullet.trs.position).GetFacingAngle(); for (float splitAngle = toPlayer - splitArc / 2 + splitOffset; splitAngle < toPlayer + splitArc / 2 + splitOffset; splitAngle += splitArc / splitNumber) { output = base.Split(bullet, VectorExtensions.FromFacingAngle(splitAngle), splitBulletPrefab, positionOffset); } ObjectPool.Instance.Despawn(bullet.prefabIndex, bullet.gameObject, bullet.trs); return(output); }
public override Bullet[] Split(Bullet bullet, Vector3 direction, Bullet splitBulletPrefab, float positionOffset = 0) { Bullet[] output = new Bullet[0]; float toPlayer = (PlayerObject.CurrentActive.trs.position - bullet.trs.position).GetFacingAngle(); for (float splitAngle = toPlayer - splitArc / 2 + splitOffset; splitAngle < toPlayer + splitArc / 2 + splitOffset; splitAngle += splitArc / splitNumber) { output = base.Split(bullet, VectorExtensions.FromFacingAngle(splitAngle), splitBulletPrefab, positionOffset); } // GameManager.GetSingleton<ObjectPool>().Despawn (bullet.prefabIndex, bullet.gameObject, bullet.trs); Destroy(bullet.gameObject); return(output); }
// #if UNITY_EDITOR public virtual void DoUpdate() { if (!update) { return; } update = false; points = new Vector2[pointCount]; for (int i = 0; i < pointCount; i++) { points[i] = VectorExtensions.FromFacingAngle((i * 360f / pointCount) * (1f / 360f) * 360) * radius; } polygonCollider2D.points = points; }
public override void Do() { index = 0; points = new Vector2[innerPointCount + outerPointCount + 2]; for (float angle = facing - innerDegrees / 2; angle <= facing + innerDegrees / 2; angle += innerDegrees / innerPointCount) { points[index] = center + VectorExtensions.FromFacingAngle(angle) * innerRadius; index++; } for (float angle = facing + outerDegrees / 2; angle >= facing - outerDegrees / 2; angle -= outerDegrees / outerPointCount) { points[index] = center + VectorExtensions.FromFacingAngle(angle) * outerRadius; index++; } polygonCollider.points = points; }
public Vector3 GetValue() { Vector3 output; Vector2 xyVector = new Vector2(); Vector2 xzVector = new Vector2(); Vector2 yzVector = new Vector2(); if (xyAngle != 0) { xyVector = VectorExtensions.FromFacingAngle(xyAngle); } if (xzAngle != 0) { xzVector = VectorExtensions.FromFacingAngle(xzAngle); } if (yzAngle != 0) { yzVector = VectorExtensions.FromFacingAngle(yzAngle); } output = new Vector3(xyVector.x + xzVector.x, xyVector.y + yzVector.x, xzVector.y + yzVector.y).normalized; direction = output; return(output); }
public virtual void SetFacing(float angle) { facingAngle = angle; facingVector = VectorExtensions.FromFacingAngle(facingAngle); }
public virtual void SpawnPlayer(Message message) { OnlinePlayer player; if (message.Count == 4) { // player = ObjectPool.Instance.SpawnComponent<OnlinePlayer>(playerPrefab.prefabIndex, new Vector2(message.GetFloat(1), message.GetFloat(2)), Quaternion.LookRotation(Vector3.forward, VectorExtensions.FromFacingAngle(message.GetFloat(3)))); player = Instantiate(playerPrefab, new Vector2(message.GetFloat(1), message.GetFloat(2)), Quaternion.LookRotation(Vector3.forward, VectorExtensions.FromFacingAngle(message.GetFloat(3)))); OnlineBattle.localPlayer = player; player.owner = GameManager.Instance.teams[0]; player.SetColor(player.owner.color); player.scoreText.text = "Score: " + player.Score; GameManager.updatables = GameManager.updatables.Add(this); // loadingText.text = "Please wait for another player to join"; if (!HasPaused) { pauseInstructionsObj.SetActive(true); } } else { // player = ObjectPool.Instance.SpawnComponent<OnlinePlayer>(playerPrefab.prefabIndex); player = Instantiate(playerPrefab); player.body.trs.position = new Vector2(message.GetFloat(1), message.GetFloat(2)); player.weapon.trs.position = new Vector2(message.GetFloat(3), message.GetFloat(4)); player.ChangeScore(message.GetUnsignedInteger(5)); player.enabled = false; GameManager.updatables = GameManager.updatables.Remove(player); OnlineBattle.nonLocalPlayers = OnlineBattle.nonLocalPlayers.Add(player); // loadingText.enabled = false; } player.playerId = message.GetInteger(0); playerIdsDict.Add(player.playerId, player); OnlineArena.Instance.SetSize((uint)playerIdsDict.Count); }
public virtual Vector2 GetPointAtAngle(float angle) { return(center + VectorExtensions.FromFacingAngle(angle) * radius); }
public virtual Event MakeEvent(Event eventPrefab, Vector2 spawnPosition = new Vector2(), float spawnRotation = 0) { return(Instantiate(eventPrefab, spawnPosition, Quaternion.LookRotation(Vector3.forward, VectorExtensions.FromFacingAngle(spawnRotation)))); }
void OnValidate() { int optionIndex = 0; for (float angle = 0; angle < 360; angle += 360f / options.Length) { options[optionIndex].trs.position = centerOptionRange.bounds.center + (trs.rotation * VectorExtensions.FromFacingAngle(angle)) * (centerOptionRange.bounds.size.x + optionSeperationFromCenterOption); optionIndex++; } }