void Start() { tempQuestionArray = questionString.ToCharArray(); alphabetManager = GetComponent <AlphabetManager> (); alphabetManager.LoadAlphabetSprite(); WordBankManager.GetInstance().LoadDictionaryFromTextFile(); calculateGridDimensionsAndCreateEMptyGrid(currentNoOfRow, currentNoOfCol); destructionArry = new List <Button> (); remaingLetter = new List <char> (); remaingLetter.AddRange(tempQuestionArray); }
public override void ForceReload() { if (Ammo != MaxAmmo && ReloadTimeRemaining <= 0) { Ammo = 0; ReloadTimeRemaining = BaseReloadTime; AlphabetManager.SpawnFloatingText("Reloading", new Vector3(transform.position.x, transform.position.y, -35)); } }
private void LoadFile(OpenFileDialog odf) { if (odf.ShowDialog() == DialogResult.OK) { string filePath = odf.FileName; AlphabetParser alphabetParser = new AlphabetParser(); alphabetManager = new AlphabetManager(alphabetParser.ParseFile(filePath)); txtFile.Text = Path.GetFileNameWithoutExtension(filePath); trvAlphabetGroups.Nodes.Clear(); trvAlphabetGroups.Nodes.AddRange(GetTreeNodes(this.alphabetManager.Alphabet.RootGroups).ToArray()); cboSelectionMethod.Items.Clear(); UpdateSelectedCharacters(); foreach (SelectionMethod mode in (SelectionMethod[])Enum.GetValues(typeof(SelectionMethod))) { cboSelectionMethod.Items.Add(mode); } cboTypeMode.ValueMember = "ID"; cboTypeMode.DisplayMember = "Name"; cboTypeMode.DataSource = new BindingSource(alphabetManager.Alphabet.InputOptions, null); cboDisplayMode.ValueMember = "ID"; cboDisplayMode.DisplayMember = "Name"; cboDisplayMode.DataSource = new BindingSource(alphabetManager.Alphabet.DisplayOptions, null); lblInstructions.Text = "Select alphabet group"; cboSelectionMethod.SelectedItem = selectionMethod; cboDisplayMode.SelectedIndex = cboDisplayMode.FindStringExact( alphabetManager.Alphabet.DefaultDisplay.ID ); cboTypeMode.SelectedIndex = cboTypeMode.FindStringExact( alphabetManager.Alphabet.DefaultInput.ID ); //analyticsForm = new FrmAverages(); //btnAnalytics.Enabled = true; } }
// Update is called once per frame void Update() { if (UniversalReference.MouseScreenPosDelta != new Vector2(0, 0)) { if (ActivelyAiming) { gunRotatorHand.AimGun(UniversalReference.MouseWorldPos); } else { gunRotatorHand.HoldGun(UniversalReference.MouseWorldPos); } } Vector2 MouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); entity.LookingToward = MouseWorldPos; //true if looking right, false if looking left bool LookingRight = entity.LookingToward.x > transform.position.x; //decreasing active cooldowns if (CurrShootingWindDownDuration > 0) { //when decreasing cooldowns, always use Time.deltaTime (the time it took to render last frame, in seconds) - framerate independent CurrShootingWindDownDuration -= Time.deltaTime; } if (CurrShootingCooldown > 0) { CurrShootingCooldown -= Time.deltaTime; } //inaccuracy Inaccuracy += UniversalReference.PlayerRb.velocity.magnitude / 30; //inaccuracy starts decreasing only when it has not increased if (Inaccuracy <= InaccuracyInLastFrame && InaccuracyRecoveryBlock <= 0) { if (Inaccuracy > InaccuracyMin) { Inaccuracy -= Time.deltaTime * InaccuracyRecoveryFactor; //decreased by 1 every second (can be different for balance purposes) } } if (InaccuracyRecoveryBlock > 0) { InaccuracyRecoveryBlock -= Time.deltaTime; } if (Inaccuracy > InaccuracyMax) { Inaccuracy = InaccuracyMax; } if (Inaccuracy < InaccuracyMin) { Inaccuracy = InaccuracyMin; } InaccuracyInLastFrame = Inaccuracy; /* * * //when not firing/aiming, hold the gun in resting position * if(Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1) || CurrShootingWindDownDuration > 0) * { * smg.ActivelyAiming = true; * } * else * { * smg.ActivelyAiming = false; * } * */ #region Movement //movement vector will hold information about direction, speed is added after, in Entity script //you cannot walk when mouse is dragging a window, that causes problems (though MovementVector has to be set to 0 stop previous movement) Vector2 MovementVector = new Vector2(0, 0); if (MouseInterceptor.IsMouseAvailable()) { if (Input.GetKey(KeybindManager.MoveUp)) { MovementVector += new Vector2(0, 1); LegsManager.RequestRunUp(LookingRight); } if (Input.GetKey(KeybindManager.MoveDown)) { MovementVector += new Vector2(0, -1); LegsManager.RequestRunDown(LookingRight); } if (Input.GetKey(KeybindManager.MoveLeft)) { MovementVector += new Vector2(-1, 0); LegsManager.RequestRunLeft(LookingRight); } if (Input.GetKey(KeybindManager.MoveRight)) { MovementVector += new Vector2(1, 0); LegsManager.RequestRunRight(LookingRight); } entity.MoveInDirection(MovementVector); } if (MovementVector.x < 0.01f && MovementVector.x > -0.01f && MovementVector.y < 0.01f && MovementVector.y > -0.01f) { LegsManager.RequestIdle(entity.LookingToward); } #endregion float HealthRatio = entity.Health / entity.MaxHealth; if (HealthRatio < 0.5f) { LowHealthOverlay.color = new Color(LowHealthOverlay.color.r, LowHealthOverlay.color.g, LowHealthOverlay.color.b, (0.5f - HealthRatio) * 0.85f ); } else { LowHealthOverlay.color = new Color(LowHealthOverlay.color.r, LowHealthOverlay.color.g, LowHealthOverlay.color.b, 0); } #region StuffForTestingPurposes if (Input.GetKeyDown(KeyCode.F10)) { //export navmap as text //hard path means Drive:/path - the complete path, not relative to application directory NavTestStatic.ExportNavMap(); Debug.Log("hi"); } if (Input.GetKeyUp(KeyCode.T)) { AlphabetManager.SpawnFloatingText("Hi!", new Vector3(transform.position.x, transform.position.y, -35)); } if (Input.GetKey(KeyCode.P)) { SpamParticlesToFuckWithFramerate(); } if (Input.GetKey(KeyCode.O)) { SpamOptimisedParticlesToFuckWithFramerate(); } if (Input.GetKey(KeyCode.I)) { SpamListParticlesToFuckWithFramerate(); } #endregion #region CheatCodes if (CheatManager.LastCheat == "GODMODE" || CheatManager.LastCheat == "GM") { entity.MaxHealth = float.MaxValue; entity.Health = float.MaxValue; entity.BaseMoveSpeed = 25; } if (CheatManager.LastCheat == "NUKE") { //ExplosionFrag.SpawnOriginal(Util.Vector3To2Int(transform.position), 100, 10); ExplosionFrag.SpawnOriginal(Util.Vector3To2Int(transform.position), 100); } if (CheatManager.LastCheat == "KILLALL" || CheatManager.LastCheat == "KA") { foreach (Entity e in GameObject.FindObjectsOfType <Entity>()) { if (e.Team == Entity.team.Enemy) { Destroy(e.gameObject); } } } if (CheatManager.LastCheat == "NAVDRAW") // Nav Draw { for (int x = 0; x < NavTestStatic.MapWidth; x++) { for (int y = 0; y < NavTestStatic.MapHeight; y++) { if (!NavTestStatic.IsTileWalkable(x, y)) { GameObject go = new GameObject(); go.transform.position = new Vector3(x, y, -10); go.AddComponent <SpriteRenderer>().sprite = UniversalReference.Pixel; go.GetComponent <SpriteRenderer>().color = new Color(1, 0, 0, 0.6f); } } } } if (CheatManager.LastCheat == "NAVDRAWLIGHT") // Nav Draw Light { for (int x = 0; x < NavTestStatic.MapWidth; x++) { for (int y = 0; y < NavTestStatic.MapHeight; y++) { if (!NavTestStatic.CanLightPassThroughTile(x, y)) { GameObject go = new GameObject(); go.transform.position = new Vector3(x, y, -10); go.AddComponent <SpriteRenderer>().sprite = UniversalReference.Pixel; go.GetComponent <SpriteRenderer>().color = new Color(1, 1, 0, 0.6f); } } } } if (CheatManager.LastCheat == "NAVDRAWEXPLOSION") // Nav Draw Explosion { for (int x = 0; x < NavTestStatic.MapWidth; x++) { for (int y = 0; y < NavTestStatic.MapHeight; y++) { if (!NavTestStatic.CanExplosionPassThroughTile(new Vector2Int(x, y))) { GameObject go = new GameObject(); go.transform.position = new Vector3(x, y, -10); go.AddComponent <SpriteRenderer>().sprite = UniversalReference.Pixel; go.GetComponent <SpriteRenderer>().color = new Color(1, 0.5f, 0, 0.6f); } } } } //deals 10 000 damage to every enemy entity if (CheatManager.LastCheat == "KARTHUS") // Karthus { foreach (Entity e in GameObject.FindObjectsOfType <Entity>()) { if (e.Team == Entity.team.Enemy) { e.TakeDamage(10000, DamagerInflicter.WeaponTypes.Undefined); } } } //sets every enemy entity's base movespeed to 0 if (CheatManager.LastCheat == "FREEZE") // Freeze { foreach (Entity e in GameObject.FindObjectsOfType <Entity>()) { if (e.Team == Entity.team.Enemy) { e.BaseMoveSpeed = 0; } } } //sets every enemy entity's team to player if (CheatManager.LastCheat == "CHARM") // Charm { foreach (Entity e in GameObject.FindObjectsOfType <Entity>()) { if (e.Team == Entity.team.Enemy) { e.Team = Entity.team.Player; } } } //teleport player to cursor location if (CheatManager.LastCheat == "TP") // Tp (teleport) { Vector2 Target = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = new Vector3(Target.x, Target.y, 0); } //deals 10 000 damage to every environment object if (CheatManager.LastCheat == "EARTHQUAKE") // Earthquake { //not doing this with simple foreach as something messes with the collection, i think its the wallsegments or something //EDIT: the problem still exists, only +- 90% of walls are destroyed, some remain, and can be destroyed by weapons, but not with this EnvironmentObject[] e = GameObject.FindObjectsOfType <EnvironmentObject>(); int limit = e.Length; for (int i = 0; i < limit; i++) { if (e[i] != null) { e[i].TakeDamage(10000); } } } #endregion #region Input if (Input.GetKeyDown(KeybindManager.UseItem)) { if (CurrentlyEquippedItem != null) { CurrentlyEquippedItem.DoYourThing(); } } if (Input.GetKeyUp(KeyCode.F5)) { SaverLoader.QuickSave(spriteManagerHand); } //quickload if (Input.GetKeyUp(KeyCode.F6)) { SaverLoader.QuickLoad(spriteManagerHand); //Debug.Log("Quickload Complete."); } if (Input.GetKey(KeybindManager.MousePrimary) && MouseInterceptor.IsMouseAvailable()) { CurrentlyEquippedWeapon.TryShooting(MouseWorldPos); } if (Input.GetKey(KeybindManager.AltFire)) { CurrentlyEquippedWeapon.TryAltFire(); CurrentlyEquippedWeapon.TryAltFire(MouseWorldPos); } if (Input.GetKey(KeybindManager.Reload)) { CurrentlyEquippedWeapon.ForceReload(); } #endregion }
private void Start() { manager = FindObjectOfType <AlphabetManager>(); }
// Update is called once per frame private void FixedUpdate() { if (!HuntingMode) { if (CurrPatience <= 0) { AlphabetManager.SpawnFloatingText("I'm coming for you!", new Vector3(transform.position.x, transform.position.y, -35)); HuntingMode = true; } } //if you are frozen because of your reaction time, return to skip all the rest if (CurrReactionTimeFreeze > 0) { CurrReactionTimeFreeze -= Time.deltaTime; return; } if (DontChangeDirectionFor > 0) { DontChangeDirectionFor -= Time.deltaTime; } Vector2Int MyPos = Util.Vector3To2Int(transform.position); Vector2Int TargetPos = Util.Vector3To2Int(target.position); //line of sight toward target (player) - null if obstructed List <Vector2Int> LineOfSight = NavTestStatic.GetLineOfSightOptimised(MyPos, TargetPos); //if you have a vision of player if (LineOfSight != null) { //if you have patience, freeze if hes coming from behind if (!HuntingMode) { CurrReactionTimeFreeze = Mathf.Abs(Vector2.SignedAngle(AimDirection, Util.GetVectorToward(transform, target))) / 180 * ReactionTime; //patience reduces more if player attacks from behind CurrPatience -= CurrReactionTimeFreeze; CurrReactionTimeFreeze -= 0.1f; DontChangeDirectionFor = DontChangeDirectionForBase; //patience reduces every time player is seen, and also for the duration enemy is reaction frozen } //aim toward player AimDirection = Util.GetVectorToward(transform, target); //rotate gun toward player if (gunRotatorHand != null) { gunRotatorHand.AimGun((Vector2)transform.position + AimDirection); } //if frozen, stop if (CurrReactionTimeFreeze > 0) { return; } float DistanceToTarget = (transform.position - target.position).magnitude; if (DistanceToTarget < MaxDistanceToShootFrom) { e.StopMoving(); //50-50 chance to either shoot at player current position if (Util.Coinflip()) { weapon.TryShooting(target.position); } //or predict his movement else { weapon.TryShooting( (Vector2)target.position + (targetRb.velocity * (DistanceToTarget / 20)) ); } } else { e.MoveInDirection(Util.GetVectorToward(transform, target)); } } //you dont see player else { //you are out of patience - pathfind toward him if (HuntingMode) { if (wn.WayPoints.Count <= 1) { List <Vector2> path = NavTestStatic.FindAPath(MyPos, TargetPos); if (path != null) { wn.WayPoints = path; } } if (wn.WayPoints.Count != 0) { AimDirection = Util.GetVectorToward(transform, wn.WayPoints[wn.WayPoints.Count - 1]); } if (gunRotatorHand != null) { gunRotatorHand.AimGun(Util.RotateVector(Vector2.right, e.spriteManager.GetLastDirection())); } } //you still have patience - walk around normally else { if (WalkTimeRemaining >= 0) { WalkTimeRemaining -= Time.deltaTime; e.MoveInDirection(AimDirection); } else if (DontChangeDirectionFor <= 0) { WalkTimeRemaining = Random.Range(0.5f, 5); AimDirection = Util.RotateVector(Vector2.right, Random.Range(0, 360)); } if (gunRotatorHand != null) { gunRotatorHand.AimGun((Vector2)transform.position + AimDirection); } } } e.LookingToward = AimDirection; e.spriteManager.LookTowardAngle(Vector2.SignedAngle(Vector2.right, AimDirection)); }
private void Awake() { DontDestroyOnLoad(gameObject); Instance = this; PullAlphabets(); }