Esempio n. 1
0
        public static void SaveEndWave()
        {
            WebGLJump.SaveData(SaveKeys.Money, Money.ToString());

            for (int i = 0; i < Objectives.activeTasks.Length; ++i)
            {
                WebGLJump.SaveData(SaveKeys.ObjectivesActive + i.ToString(), Objectives.activeTasks[i].ToString());
            }
            WebGLJump.SaveData(SaveKeys.ObjectivesComplete, AmountOfObjectivesComplete.ToString());

            for (int i = 0; i < BlocksLoaded.Length; ++i)
            {
                WebGLJump.SaveData(SaveKeys.BlocksLoaded + i.ToString(), BlocksLoaded[i].ToString());
            }
            for (int i = 0; i < AmmoLoaded.Length; ++i)
            {
                WebGLJump.SaveData(SaveKeys.AmmoLoaded + i.ToString(), AmmoLoaded[i].ToString());
            }

            WebGLJump.SaveData(SaveKeys.ShotsFired, ShotsFired.ToString());
            WebGLJump.SaveData(SaveKeys.TimesDefeated, TimesDefeated.ToString());
            WebGLJump.SaveData(SaveKeys.MatchStreak, MatchStreak.ToString());

            WebGLJump.SaveData(SaveKeys.DisconcertingObjectivesSeen, DisconcertingObjectivesSeen.ToString());
        }
Esempio n. 2
0
    void grenadeUpdate()
    {
        bool activated = false;

        TutorialCombat.updateAoE(GetComponent<TutorialManager>(), ref activated);

        if (activated)
        {

            List<GameObject> targets = TutorialCombat.getTargets();

            foreach(GameObject target in targets)
            {
                TutorialManager enemy = target.GetComponent<TutorialManager>();
                ShotsFired shot = new ShotsFired(this.transform.position,
                                                 enemy.transform.position,
                                                 enemy.getActiveUnitsCount(),
                                                 BalanceConstants.Ability.GRENADE_HIT_CHANCE,
                                                 enemy.dodgeChance,false);
                int damage = TutorialCombat.calculateDamage(shot);

                //enemy.nView.RPC("takeDamage", RPCMode.All, damage, false);
                enemy.takeDamage(damage,false);
            }

            squad.skipAction();
            gameLogic.checkStateEndOfAction();
            gameLogic.updateUI();
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Used to set previous values for every <see cref="AbstractVariable{T}"/>. Must use the same order and logic as the <see cref="Scan"/> method.
        /// </summary>
        public void PreScan()
        {
            PlayerID.PreScan();
            Username.PreScan();

            IsReplay.PreScan();
            if (IsReplay.Value)
            {
                return;
            }

            IsAlive.PreScan();
            Time.PreScan();
            Kills.PreScan();
            Gems.PreScan();
            ShotsFired.PreScan();
            ShotsHit.PreScan();

            if (IsAlive.Value)
            {
                EnemiesAlive.PreScan();
            }

            if (!IsAlive.Value)
            {
                DeathType.PreScan();
            }
        }
Esempio n. 4
0
    public static IEnumerator fightTarget(GameObject me, int power)
    {
        ShotsFired  myHits = detectHits(me, power);
        int         damage = calculateDamage(myHits);
        NetworkView nView  = getTarget().GetComponent <NetworkView>();

        //getTarget().GetComponent<NetworkView>().RPC("takeDamage", RPCMode.AllBuffered, damage,false);
        getTarget().GetComponent <TutorialManager>().takeDamage(damage, false);
        shootSounds = me.GetComponent <TutorialManager> ().GetComponents <AudioSource> ();
        rifleShoot  = shootSounds[1];
        sniperShoot = shootSounds[2];
        AudioClip shootClip = shootSounds[1].clip;
        int       squadSize = me.GetComponent <TutorialManager>().size;

        if (me.GetComponent <TutorialManager> ().squadType == "Rifle")
        {
            float originalPitch = rifleShoot.pitch;
            for (int i = 0; i < squadSize; i++)
            {
                rifleShoot.pitch = Random.Range(-.3f, .1f) + originalPitch;
                rifleShoot.PlayOneShot(shootClip);
                yield return(new WaitForSeconds(Random.Range(0.05f, 0.1f)));
            }
        }
        else if (me.GetComponent <TutorialManager> ().squadType == "Sniper")
        {
            sniperShoot.Play();
        }
    }
Esempio n. 5
0
    public static int calculateDamage(ShotsFired myHits)
    {
        int hits = 0;

        for (int i = 0; i < myHits.power; i++)
        {
            if (Random.value <= myHits.hitChance)
            {
                hits++;
            }
        }
        //CombatIndicationSpawner.spawnHits (myHits.source, hits);
        int damage = 0;

        for (int i = 0; i < hits; i++)
        {
            //higher dodge chance means less bullets go through
            if (Random.value >= myHits.dodgeChance)
            {
                damage++;
            }
        }
        //CombatIndicationSpawner.spawnMisses (myHits.destination, hits-damage);
        return(damage);
    }
Esempio n. 6
0
        private async void DoShootBullets(object sender, DoWorkEventArgs e)
        {
            int bulletsshot = 0;

            while (bulletsshot < 5)
            {
                // Release bullets
                for (int ang = 0; ang < 360; ang += 60)
                {
                    Debug.WriteLine("Shooting bullet towards angle {0}", ang);
                    double spawnX, spawnY;
                    spawnX = CurrentCharacter.Position.X += 5 * Math.Cos(ang);
                    spawnY = CurrentCharacter.Position.Y -= 5 * Math.Sin(ang);
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                    {
                        ShotsFired.Add(new BulletNPC(CurrentCharacter.Position, ang, (int)spawnX, (int)spawnY));
                    });
                }

                LastBulletRelease = DateTime.Now;
                bulletsshot++;
                await Task.Delay((int)BulletReleaseTimeSpan.TotalMilliseconds);
            }
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                ShotsFired.Clear();
            });
        }
Esempio n. 7
0
        public override Coordinate Attack()
        {
            Console.WriteLine();
            Console.Write("The Computer will attack...");

            System.Threading.Thread.Sleep(1000);

            //TODO: The computer should not fire randomly after a hit. it should try the squares next to the hit, until it shinks a ship.

            while (true)
            {
                Coordinate next = new Coordinate()
                {
                    x = Game.Rnd.Next(0, 10) + 1, y = Game.Rnd.Next(0, 10) + 1
                };
                if (ShotsFired.Exists(c => c.Equals(next)))
                {
                    continue;
                }
                else
                {
                    Console.WriteLine(next.ToString());
                    return(next);
                }
            }
        }
        public void Shoot(IList <Soldier> soldiers)
        {
            // 0 is not a magic number, refers to empty, nothing, default, dead, etc..
            var isDead = HP <= 0;

            if (isDead)
            {
                return;
            }

            Soldier target = PickRandomTarget(soldiers);

            // Logging has been decoupled.
            // Usign event instead, which is still part of shooting (still doing one thing).
            ShotsFired?.Invoke(this, new ShotFiredEventArgs(Name, target.Name));

            // 100 is not a magic number, usually refers to 100%.
            var hitRoll = _random.Next(100);

            if (IsTargetHit(hitRoll))
            {
                _consequitiveShots++;
                DealDamage(target);
            }
            else
            {
                _consequitiveShots = 0;
            }
        }
Esempio n. 9
0
    void grenadeUpdate()
    {
        bool activated = false;

        TutorialCombat.updateAoE(GetComponent <TutorialManager>(), ref activated);

        if (activated)
        {
            List <GameObject> targets = TutorialCombat.getTargets();

            foreach (GameObject target in targets)
            {
                TutorialManager enemy = target.GetComponent <TutorialManager>();
                ShotsFired      shot  = new ShotsFired(this.transform.position,
                                                       enemy.transform.position,
                                                       enemy.getActiveUnitsCount(),
                                                       BalanceConstants.Ability.GRENADE_HIT_CHANCE,
                                                       enemy.dodgeChance, false);
                int damage = TutorialCombat.calculateDamage(shot);

                //enemy.nView.RPC("takeDamage", RPCMode.All, damage, false);
                enemy.takeDamage(damage, false);
            }

            squad.skipAction();
            gameLogic.checkStateEndOfAction();
            gameLogic.updateUI();
        }
    }
Esempio n. 10
0
 public string FormatShots(bool history)
 {
     if (history && (ShotsHit == 0 || ShotsFired == 10000))
     {
         return("Exact values not known");
     }
     return($"{ShotsHit.ToString("N0")} / {ShotsFired.ToString("N0")}");
 }
Esempio n. 11
0
 public void moveBullets()
 {
     if (ShotsFired.Count != 0)
     {
         ShotsFired.ToList().ForEach(shot =>
         {
             shot.move();
         });
     }
 }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     mTime                      = 0;
     fDelay                     = 0;
     BallPos.x                  = 0;
     BallPos.y                  = 2;
     BallPos.z                  = 0;
     rigidbody.useGravity       = false;
     bCanShoot                  = true;
     bCanReset                  = true;
     reticle.collider.enabled   = false;
     reticle.transform.position = new Vector3(rigidbody.position.x, rigidbody.position.y, rigidbody.position.z);
     shotsLeft                  = ShotsFired.GetShotsFired(gameObject);
 }
Esempio n. 13
0
 public void OnShoot()
 {
     while (true)
     {
         if (rng.Next(0, 100) % 2 == 0)
         {
             ShotsFired?.Invoke(this, new ShotsFiredEventArgs(DateTime.Now));
         }
         else
         {
             Console.WriteLine("I missed!");
         }
         Thread.Sleep(500);
     }
 }
Esempio n. 14
0
        public void OnShoot()
        {
            while (true)
            {
                if (rng.Next(0, 100) % 2 == 0)
                {
                    ShotsFired?.Invoke(this, new ShotsFiredEventArgs(DateTime.Now)); // EventName? means if Event is not Null (if it has subscribers)
                }
                else
                {
                    Console.WriteLine("I Missed!");
                }

                Thread.Sleep(1000);
            }
        }
Esempio n. 15
0
        public bool EnemiesHitByBullet(Character c)
        {
            //List<Character> enemiesShot = Characters.Where(ch => ShotsFired.Exists(shot => shot.overlapsCircle(ch))).ToList();
            foreach (BulletNPC bullet in ShotsFired)
            {
                if (bullet.overlapsCircle(c))
                {
                    // Remove bullet when it hits a first object
                    ShotsFired.Remove(bullet);
                    // return the character
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 16
0
        /// <summary>
        /// Play attack animation
        /// </summary>
        public void Attack()
        {
            if (_shootWaitTime < MaxShootIntervals)
            {
                return;
            }
            var playerWindow = _playerWindow;
            var x            = CurrentDirection == Direction.Right ? 30f : -30f;
            var pos          = new Vector2f(Position.X + x, Position.Y);

            ShotsFired.Add(new Shot(ref playerWindow, Name + "Shot", pos)
            {
                Direction = CurrentDirection
            });
            _shotSound?.Play();
            _shootWaitTime = 0;
        }
Esempio n. 17
0
 public static int calculateDamage(ShotsFired myHits)
 {
     int hits = 0;
     for (int i = 0; i < myHits.power; i++)
     {
         if (Random.value <= myHits.hitChance) hits++;
     }
     CombatIndicationSpawner.spawnHits (myHits.source, hits);
     int damage = 0;
     for (int i = 0; i < hits; i++)
     {
         //higher dodge chance means less bullets go through
         if (Random.value >= myHits.dodgeChance) damage++;
     }
     CombatIndicationSpawner.spawnMisses (myHits.destination, hits-damage);
     return damage;
 }
Esempio n. 18
0
    void shotBlastUpdate()
    {
        if (Combat.UpdateTarget(squad))
        {
            ShotsFired blast = new ShotsFired(this.transform.position,
                                              Combat.getTarget().transform.position,
                                              squad.getPower(),
                                              squad.hitChance,
                                              Combat.getTarget().GetComponent <SquadManager>().dodgeChance,
                                              false);
            int damage = Combat.calculateDamage(blast);

            //Combat.getTarget().GetComponent<SquadManager>().takeDamage(damage,true);
            Combat.getTarget().GetComponent <NetworkView>().RPC("takeDamage", RPCMode.All, damage, true);
            squad.skipAction();
            gameLogic.checkStateEndOfAction();
            gameLogic.updateUI();
        }
    }
Esempio n. 19
0
    void sniperShotUpdate()
    {
        if (Combat.UpdateTarget(GetComponent <SquadManager>()))
        {
            ShotsFired snipe = new ShotsFired(this.transform.position,
                                              Combat.getTarget().transform.position,
                                              BalanceConstants.Ability.SNIPE_POWER,
                                              BalanceConstants.Ability.SNIPE_HIT_CHANCE,
                                              Combat.getTarget().GetComponent <SquadManager>().dodgeChance,
                                              false);
            int damage = Combat.calculateDamage(snipe);

            //Combat.getTarget().GetComponent<SquadManager>().takeDamage(damage,true);
            Combat.getTarget().GetComponent <NetworkView>().RPC("takeDamage", RPCMode.All, damage, true);
            squad.skipAction();
            gameLogic.checkStateEndOfAction();
            gameLogic.updateUI();
        }
    }
Esempio n. 20
0
 public void OnShoot()
 {
     while (true)
     {
         if (rng.Next(0, 100) % 2 == 0)
         {
             //if(ShotsFired != null)
             //{
             //    ShotsFired.Invoke(this, new ShotsFiredEventArgs(DateTime.Now));
             //}
             //replace with
             ShotsFired?.Invoke(this, new ShotsFiredEventArgs(DateTime.Now));
         }
         else
         {
             Console.WriteLine("I Missed!");
         }
         Thread.Sleep(500);
     }
 }
Esempio n. 21
0
        /// <summary>
        /// Attack the player
        /// </summary>
        public void Attack()
        {
            if (_timeSinceLastShot >= ShotSpeed)
            {
                var window   = (RenderWindow)_renderTarget;
                var x        = CurrentDirection == Direction.Right ? 30f : -30f;
                var pos      = new Vector2f(Position.X + x, Position.Y);
                var shotName = "";
                switch (Type)
                {
                case EnemyType.Nurse:
                    shotName = "Needle";
                    break;

                case EnemyType.Teenager:
                    shotName = "Skateboard";
                    break;

                case EnemyType.GrimReeper:
                    shotName = "Sycth";
                    break;

                case EnemyType.FuneralHomeDirector:
                    shotName = "Tombstone";
                    break;
                }
                ShotsFired.Add(new Shot(ref window, shotName, pos)
                {
                    Direction = CurrentDirection
                });
                //_shotSound.Play();
                _timeSinceLastShot = 0;
            }
            else
            {
                _timeSinceLastShot += GameMaster.Delta.AsSeconds();
            }
        }
Esempio n. 22
0
        // Now we need a method that will invoke this event
        public void OnShoot()
        {
            while (true)                       // Infinite loop
            {
                if (rng.Next(0, 100) % 2 == 0) // 50% chance to kill
                {
                    if (ShotsFired != null)    // Everytime we call on events, we need to check to see if the event is empty. If NOT EMPTY (then it has some subscribers), then INVOKE
                    {
                        // Raising the event using Invoke. In here we put the signature of our delegate. Who is our sender, who is raising the event? The Shooter class.
                        // We will need to use the this keyword, then we can pass empty EventArgs for now
                        ShotsFired.Invoke(this, new ShotsFiredEventArgs()
                        {
                            TimeOfKill = DateTime.Now
                        });                                                                             // "this" is what sends information about the object that raises the event. If we put the name property here like above, our subscriber methods will have access to them
                    }
                }
                else
                {
                    Console.WriteLine("I missed!");
                }

                Thread.Sleep(500);
            }
        }
Esempio n. 23
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Assistants?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ DeathDisposition.GetHashCode();
         hashCode = (hashCode * 397) ^ ImpulseId.GetHashCode();
         hashCode = (hashCode * 397) ^ IsAssassination.GetHashCode();
         hashCode = (hashCode * 397) ^ IsGroundPound.GetHashCode();
         hashCode = (hashCode * 397) ^ IsHeadshot.GetHashCode();
         hashCode = (hashCode * 397) ^ IsMelee.GetHashCode();
         hashCode = (hashCode * 397) ^ IsShoulderBash.GetHashCode();
         hashCode = (hashCode * 397) ^ IsWeapon.GetHashCode();
         hashCode = (hashCode * 397) ^ (Killer?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ KillerAgent.GetHashCode();
         hashCode = (hashCode * 397) ^ (KillerWeaponAttachmentIds?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ KillerWeaponStockId.GetHashCode();
         hashCode = (hashCode * 397) ^ (KillerWorldLocation?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MedalId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Player?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ RoundIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ ShotsFired.GetHashCode();
         hashCode = (hashCode * 397) ^ ShotsLanded.GetHashCode();
         hashCode = (hashCode * 397) ^ TimeWeaponActiveAsPrimary.GetHashCode();
         hashCode = (hashCode * 397) ^ (Victim?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ VictimAgent.GetHashCode();
         hashCode = (hashCode * 397) ^ (VictimAttachmentIds?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ VictimStockId.GetHashCode();
         hashCode = (hashCode * 397) ^ (VictimWorldLocation?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (WeaponAttachmentIds?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ WeaponStockId.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)EventName;
         hashCode = (hashCode * 397) ^ TimeSinceStart.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 24
0
        public void Scan()
        {
            try
            {
                // Always scan these values.
                PlayerID.Scan();
                Username.Scan();

                // Always calculate the spawnset in menu or lobby.
                // Otherwise you can first normally load a spawnset to set the hash, exit and load an empty spawnset in the menu/lobby, then during playing the empty spawnset change it back to the same original spawnset and upload a cheated score.
                if (Time.Value == 0 && Time.ValuePrevious == 0)
                {
                    SpawnsetHash = CalculateCurrentSurvivalHash();
                }

                // Stop scanning if it is a replay.
                IsReplay.Scan();
                if (IsReplay.Value)
                {
                    return;
                }

                IsAlive.Scan();
                Time.Scan();
                Kills.Scan();
                Gems.Scan();
                ShotsFired.Scan();
                ShotsHit.Scan();

                if (IsAlive.Value)
                {
                    // Enemy count might increase on death, so only scan while player is alive.
                    EnemiesAlive.Scan();

                    // TODO: Clean up
                    byte[] bytes = Memory.Read(Process.MainModule.BaseAddress + 0x001F8084, 4, out _);
                    int    ptr   = AddressUtils.ToDec(AddressUtils.MakeAddress(bytes));
                    bytes     = Memory.Read(new IntPtr(ptr), 4, out _);
                    ptr       = AddressUtils.ToDec(AddressUtils.MakeAddress(bytes));
                    bytes     = Memory.Read(new IntPtr(ptr) + 0x218, 4, out _);
                    LevelGems = BitConverter.ToInt32(bytes, 0);

                    bytes  = Memory.Read(new IntPtr(ptr) + 0x224, 4, out _);
                    Homing = BitConverter.ToInt32(bytes, 0);
                    HomingLog.Add(Homing);
                    if (HomingLog.Count > 5)
                    {
                        HomingLog.Remove(HomingLog[0]);
                    }

                    if (LevelUpTimes[0] == 0 && LevelGems >= 10 && LevelGems < 70)
                    {
                        LevelUpTimes[0] = Time.Value;
                    }
                    if (LevelUpTimes[1] == 0 && LevelGems == 70)
                    {
                        LevelUpTimes[1] = Time.Value;
                    }
                    if (LevelUpTimes[2] == 0 && LevelGems == 71)
                    {
                        LevelUpTimes[2] = Time.Value;
                    }
                }
                else
                {
                    // Only scan death type when dead.
                    DeathType.Scan();
                }

                if (string.IsNullOrEmpty(SpawnsetHash))
                {
                    SpawnsetHash = CalculateCurrentSurvivalHash();
                }
            }
            catch (Exception ex)
            {
                Logging.Log.Error("Scan failed", ex);
            }
        }
Esempio n. 25
0
 public string FormatShots()
 {
     return($"{ShotsHit.ToString("N0")} / {ShotsFired.ToString("N0")}");
 }
 public void ShotFired()
 {
     ShotsFired.IncreaseValue(1);
 }
Esempio n. 27
0
    void sniperShotUpdate()
    {
        if (Combat.UpdateTarget(GetComponent<SquadManager>()))
        {
            ShotsFired snipe = new ShotsFired(this.transform.position,
                                              Combat.getTarget().transform.position,
                                              BalanceConstants.Ability.SNIPE_POWER,
                                              BalanceConstants.Ability.SNIPE_HIT_CHANCE,
                                              Combat.getTarget().GetComponent<SquadManager>().dodgeChance,
                                              false);
            int damage = Combat.calculateDamage(snipe);

            //Combat.getTarget().GetComponent<SquadManager>().takeDamage(damage,true);
            Combat.getTarget().GetComponent<NetworkView>().RPC("takeDamage", RPCMode.All, damage, true);
            squad.skipAction();
            gameLogic.checkStateEndOfAction();
            gameLogic.updateUI();
        }
    }