Beispiel #1
0
        private void Test()
        {
            if (RaceIsOn)
            {
                throw new Exception("Гонка уже началась! Сначала остановите гонку");
            }

            Bolides.AddRange(new List <Bolide>()
            {
                new Bolide("Ferrari", TrackWidth, TrackHeight),
                new Bolide("RedBull", TrackWidth, TrackHeight),
                new Bolide("ForceIndia", TrackWidth, TrackHeight),
                new Bolide("Mercedes", TrackWidth, TrackHeight),
            });
            foreach (Bolide bolide in Bolides)
            {
                Mechanic mechanic = new Mechanic(bolide.Name, bolide);
                mechanic.SetPosition(TrackWidth, TrackHeight);
                Mechanics.Add(mechanic);

                ReparingLoader repaing = new ReparingLoader(bolide.Name, bolide);
                repaing.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(repaing);

                SafetyCar safety = new SafetyCar(bolide.Name, bolide);
                safety.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(safety);
            }
        }
Beispiel #2
0
        private void RollInitiative()
        {
            var random = new Random();

            // creatures with the same name are grouped in the same initative
            var namedict = new Dictionary <string, int>();

            foreach (var c in encounter.Creatures)
            {
                if (!c.IsPC)
                {
                    if (groupByName)
                    {
                        if (namedict.ContainsKey(c.Name))
                        {
                            c.Initiative = namedict[c.Name];
                        }
                        else
                        {
                            c.Initiative = random.Next(20) + Mechanics.GetModifier(c.Dexterity);
                            namedict.Add(c.Name, c.Initiative);
                        }
                    }
                    else
                    {
                        c.Initiative = random.Next(20) + Mechanics.GetModifier(c.Dexterity);
                    }
                }
            }

            encounter.Creatures.Sort(CreatureViewModel.CompareInitiative);

            rolled = true;
        }
Beispiel #3
0
        public void ApplyStrategy(Creature monster, World world)
        {
            monster.Character.Target = world.GetNearestEnemyTarget(monster, (int)monster.BoundRect.BottomCenter.X, (int)monster.BoundRect.BottomCenter.Y, new List <string>());
            if (monster.Character.Target != null && monster.Character.Target.Character.Entity.EntityClass == "Warrior")
            {
                monster.CombatStrategy = new MageAiVsWarrior();
                return;
            }
            else
            {
                if (monster.CastTimer.TotalSeconds < 2)
                {
                    int   spellNumber = Mechanics.Roll(0, 21);
                    Spell spell       = monster.Character.Entity.Spells.ElementAt(Mechanics.Roll(0, monster.Character.Entity.Spells.Count)).Value;
                    monster.CastTimer = TimeSpan.FromSeconds(Mechanics.Roll(6, 12));

                    world.ApplySpell(monster, spell, monster.Character.Target, false, false);
                }
                else
                {
                    Spell spell;
                    if (monster.Character.Entity.Spells.TryGetValue("Frost Bolt", out spell))
                    {
                        world.ApplySpell(monster, spell, monster.Character.Target, false, false);
                    }
                }
            }
        }
Beispiel #4
0
 public void Dispose()
 {
     Buses.Dispose();
     BusStatuses.Dispose();
     Mechanics.Dispose();
     Workshops.Dispose();
 }
Beispiel #5
0
        public void LevelUp()
        {
            Level++;

            string[] parts = HealthCalculation.Split('|');

            int amount = int.Parse(parts[0]) + Mechanics.RollDie((DieType)int.Parse(parts[2]));

            Health.SetMaximum(amount + Health.MaximumValue);
            Health.Heal((ushort)amount);

            if (Mana.MaximumValue > 0)
            {
                parts = ManaCalculation.Split('|');

                amount = int.Parse(parts[0]) + Mechanics.RollDie((DieType)int.Parse(parts[2]));

                Mana.SetMaximum(amount + Mana.MaximumValue);
                Mana.Heal((ushort)amount);
            }
            else
            {
                parts = StaminaCalculation.Split('|');

                amount = int.Parse(parts[0]) + Mechanics.RollDie((DieType)int.Parse(parts[2]));

                Stamina.SetMaximum(amount + Stamina.MaximumValue);
                Stamina.Heal((ushort)amount);
            }
        }
Beispiel #6
0
 public override void Attack(Entity source)
 {
     if (Mechanics.RollDie(DieType.D20) >= 10 + Mechanics.GetModifier(entity.Dexterity))
     {
         entity.ApplyDamage(source.MainHand);
     }
 }
        public TotalCostView InsertUpdateMaintenanceCost(Mechanics mechanics)
        {
            using (var context = new InsightsDBEntities())
            {
                var record = context.Mechanics
                             .SingleOrDefault(x => x.Year == mechanics.Year &&
                                              x.BuildingId == mechanics.BuildingId && x.Type == mechanics.Type);
                if (record == null)
                {
                    mechanics.IsActive  = true;
                    mechanics.CreatedOn = DateTime.Now;
                    mechanics.UpdatedOn = DateTime.Now;
                    context.Mechanics.Add(mechanics);
                    context.SaveChanges();
                }
                else
                {
                    record.UpdatedOn = DateTime.Now;
                    record.Cost      = mechanics.Cost;
                    context.SaveChanges();
                }
            }
            TotalCostView tcv = new TotalCostView();

            tcv.BuildingId = mechanics.BuildingId;
            tcv.Year       = mechanics.Year;
            tcv.Type       = mechanics.Type.ToString();
            return(GetMaintenanceCost(tcv));
        }
        public void RemoveService(int id)
        {
            Mechanics v = db.Mechanics.Find(id);

            db.Mechanics.Remove(v);
            db.SaveChanges();
        }
Beispiel #9
0
        public static void Game_OnTick(EventArgs args)
        {
            _game.AutoBuyTrinkets();
            _game.FocusW();
            _game.autoBuy();
            _game.LevelUpSpells();
            _game.AutoPotions();
            _game.LowlifeE();
            _game.QKs();

            AutoE.OnExecute();

            Mechanics.FlashE();
            Mechanics.Insec();

            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Harass))
            {
                Modes.Harass.Load();
            }
            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.JungleClear))
            {
                Modes.JungleClear.Load();
            }
            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Flee))
            {
                Modes.Flee.Load();
            }
            if (Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.Combo))
            {
                Modes.Combo.Load();
            }
            //if ((Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.LaneClear)) ||
            //(Orbwalker.ActiveModesFlags.HasFlag(Orbwalker.ActiveModes.LastHit))) Modes.LCLH.Load();
            //if (MenuManager.ComboMenu["AAReset"].Cast<CheckBox>().CurrentValue) _game.EloBuddyOrbDisabler();
        }
 public List <MechanicsCostView> InsertUpdateMechanicsCostByType(Mechanics mechanics)
 {
     using (var context = new InsightsDBEntities())
     {
         var result = context.Mechanics
                      .SingleOrDefault(x => x.Type == mechanics.Type &&
                                       x.Year == mechanics.Year &&
                                       x.BuildingId == mechanics.BuildingId);
         if (result == null)
         {
             mechanics.IsActive  = true;
             mechanics.CreatedOn = DateTime.Now;
             mechanics.UpdatedOn = DateTime.Now;
             context.Mechanics.Add(mechanics);
             context.SaveChanges();
         }
         else
         {
             result.Cost      = mechanics.Cost;
             result.UpdatedOn = DateTime.Now;
             context.SaveChanges();
         }
     }
     return(GetMechanicsCostByType(mechanics));
 }
Beispiel #11
0
 // Use this for initialization
 void Awake()
 {
     source    = GetComponent <AudioSource>();
     mechanics = GetComponent <Mechanics> ();
     isFiring  = false;
     GameObject.Find("ResultText").GetComponentInChildren <TextMesh>().text = "";
 }
Beispiel #12
0
        public void AddMechanic(MechanicView mechanic)
        {
            Mechanics mechanics = mapper.Map <MechanicView, Mechanics>(mechanic);

            db.Mechanics.Add(mechanics);
            db.SaveChanges();
        }
        public float MagicDebuff(GameProcess player1, GameProcess player2, Mechanics Mechs)
        {
            RandVar6 = player1.rand6.NextDouble();

            if ((Conv.MagicDebuffChance(player1) / 100.0f) > RandVar6)
            {
                if (player1.magicEquipped == "Fire")
                {
                    player2.onFire     = Mechs.Convert.MagicDurationFunc(player1);
                    player2.fireDebuff = Mechs.Convert.MagicFireDebuff(player1) / 100.0f;
                }
                else if (player1.magicEquipped == "Curse")
                {
                    player2.cursed = Mechs.Convert.MagicDurationFunc(player1);
                    Debug.Log("Sleep is:" + player1.sleep + " ; " + "Duration is: " + player2.cursed);
                    player2.curseDebuff = Mechs.Convert.MagicCurseDebuff(player1) / 100.0f;
                }
                else if (player1.magicEquipped == "Bolt")
                {
                    return(2);
                }
                else if (player1.magicEquipped == "Ice")
                {
                    player2.bashed = true;
                }
            }
            return(1);
        }
Beispiel #14
0
        public void AddRacer(string Name)
        {
            if (!RaceIsOn)
            {
                Bolide newbolide = new Bolide(Name, TrackWidth, TrackHeight);
                Bolides.Add(newbolide);

                Mechanic newmechanic = new Mechanic(Name, newbolide);
                newmechanic.SetPosition(TrackWidth, TrackHeight);
                Mechanics.Add(newmechanic);


                ReparingLoader newloader = new ReparingLoader(Name, newbolide);
                newloader.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(newloader);

                SafetyCar safety = new SafetyCar(Name, newbolide);
                safety.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(safety);

                SetStartGrid();
            }
            else
            {
                throw new Exception("Гонка уже началась! Сначала остановите гонку");
            }
        }
Beispiel #15
0
        public async Task <IActionResult> OnGetAsync()
        {
            var id = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (id == null)
            {
                return(NotFound($"Unable to load user with ID '{id}'."));
            }

            var mechanic = await _db.Mechanics.FirstOrDefaultAsync(m => m.UserId == id);

            if (mechanic == null)
            {
                StatusMessage = "This user is not bound to any mechanic workshop. Please input your workshop details.";

                return(Page());
            }

            Mechanic = new Mechanics
            {
                Name       = mechanic.Name,
                Street     = mechanic.Street,
                City       = mechanic.City,
                PostalCode = mechanic.PostalCode,
                State      = mechanic.State
            };

            return(Page());
        }
Beispiel #16
0
        public Board(Battle.Configurations.Configurations configuration)
        {
            /*
             * Things the board needs to have:
             * # of Jewels
             * Jewel Dimensions (Board Configs)
             * Where Jewels are
             * Board Mechanics(Start Turn, End Turn)
             */

            this.configuration = configuration;
            boardData          = new BoardData(configuration);

            ProcessCascadeBoardMechanics   = new CascadeBoardMechanics(this);
            ProcessEndGameBoardMechanics   = new EndGameBoardMechanics(this);
            ProcessSelectBoardMechanics    = new SelectBoardMechanics(this);
            ProcessStartGameBoardMechanics = new StartGameBoardMechanics(this);
            ProcessSwapBoardMechanics      = new SwapBoardMechanics(this);
            UnselectBoardMechanics         = new UnselectBoardMechanics(this);
            ActivateAbilityMechanics       = new ActivateAbilityMechanics(this);
            InvokeActivateAbilityMechanics = new InvokeActivateAbilityMechanics(this);
            RemoveJewelBoardMechanics      = new RemoveJewelBoardMechanics(this);

            Mechanics.Add(ProcessCascadeBoardMechanics);
            Mechanics.Add(ProcessEndGameBoardMechanics);
            Mechanics.Add(ProcessSelectBoardMechanics);
            Mechanics.Add(ProcessStartGameBoardMechanics);
            Mechanics.Add(ProcessSwapBoardMechanics);
            Mechanics.Add(UnselectBoardMechanics);
            Mechanics.Add(ActivateAbilityMechanics);
            Mechanics.Add(InvokeActivateAbilityMechanics);
            Mechanics.Add(RemoveJewelBoardMechanics);
        }
Beispiel #17
0
 public override void DoAttack(Entity target)
 {
     if (Mechanics.RollDie(DieType.D20) >= 10 + Mechanics.GetModifier(target.Dexterity))
     {
         target.ApplyDamage(entity.MainHand);
     }
 }
Beispiel #18
0
        public override void Apply(Entity entity)
        {
            int amount = modifier;

            for (int i = 0; i < numberOfDice; i++)
            {
                amount += Mechanics.RollDie(dieType);
            }

            foreach (Weakness weakness in entity.Weaknesses.Where(x => x.WeaknessType == damageType))
            {
                amount = weakness.Apply(amount);
            }

            foreach (Resistance resistance in entity.Resistances.Where(x => x.ResistanceType == damageType)
            {
                amount = resistance.Apply(amount);
            }

            if (amount < 1)
                amount = 1;

            switch (attackType)
            {
                case AttackType.Health:
                    entity.Health.Damage((ushort)amount);
                    break;
                case AttackType.Mana:
                    entity.Mana.Damage((ushort)amount);
                    break;
                case AttackType.Stamina:
                    entity.Stamina.Damage((ushort)amount);
                    break;
            }
        }
        public override void Apply(Entity entity)
        {
            int amount = modifier;

            for (int i = 0; i < numberOfDice; i++)
            {
                amount += Mechanics.RollDie(dieType);
            }

            if (amount < 1)
            {
                amount = 1;
            }

            switch (healType)
            {
            case HealType.Health:
                entity.Health.Heal((ushort)amount);
                break;

            case HealType.Mana:
                entity.Mana.Heal((ushort)amount);
                break;

            case HealType.Stamina:
                entity.Stamina.Heal((ushort)amount);
                break;
            }
        }
Beispiel #20
0
        public static bool CanLearn(Entity entity, Spell spell)
        {
            bool canLearn = true;

            if (entity.Level < spell.LevelRequirement)
            {
                canLearn = false;
            }

            if (!spell.AllowedClasses.Contains(entity.EntityClass.ToLower()))
            {
                canLearn = false;
            }

            foreach (string s in spell.AttributeRequirements.Keys)
            {
                if (Mechanics.GetAttributeByString(entity, s) < spell.AttributeRequirements[s])
                {
                    canLearn = false;
                    break;
                }
            }

            foreach (string s in spell.SpellPrerequisites)
            {
                if (!entity.Talents.ContainsKey(s))
                {
                    canLearn = false;
                    break;
                }
            }

            return(canLearn);
        }
Beispiel #21
0
    void OnTriggerStay(Collider other)
    {
        var device = SteamVR_Controller.Input((int)trackedObj.index);

        if (other.attachedRigidbody)
        {
            if (grabbedObject == null && device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                grabbedObject        = other.transform.parent;
                originalObjectHeight = grabbedObject.localPosition.y;

                //only change whether you use the GRABBER x or y, rotated the object so its always using Y
                if (grabbedObject.name == "X")
                {
                    originalGrabberHeight = this.transform.parent.parent.position.x;
                }
                else if (grabbedObject.name == "Y")
                {
                    originalGrabberHeight = this.transform.parent.parent.position.y;
                }
                else if (grabbedObject.name == "FIRE")
                {
                    Mechanics mechanics = projectile.GetComponent <Mechanics> ();
                    projectile.transform.localPosition = Vector3.zero;
                    mechanics.velocity     = new Vector3(xPower.transform.localPosition.y * 50, yPower.transform.localPosition.y * 50, 0);
                    mechanics.enableMotion = true;
                    projectile.GetComponent <shot> ().Fire();
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            EventManager.TriggerEvent("trigger_pause", new object[] { });
        }

        if (mLastProceeded == (int)Time.timeSinceLevelLoad || mIsOver)
        {
            return;
        }

        if (mAdultPool.TotalMales == 0 || mAdultPool.TotalFemales == 0)
        {
            Debug.Log("GAME OVER");
            GameOver();
            return;
        }


        mYear          = (int)Time.timeSinceLevelLoad / LengthOfAYear;
        mLastProceeded = (int)Time.timeSinceLevelLoad;

        // Proceed ticked updated
        if (ShouldTick(InfantileDeathTick))
        {
            Mechanics.ProceedChildren(ref mChildrenPool, InfantMortalityRate);
        }

        if (ShouldTick(AdultDeathTick))
        {
            Mechanics.ProceedAdult(ref mAdultPool, MaleMortalityRate, FemaleMortalityRate, MaleMortalityModifier, FemaleMortalityModifier);
        }

        EventManager.TriggerEvent("population_update", new object[] {
            mAdultPool.TotalMales, mAdultPool.TotalFemales, ChildrenPopulation, MaximumPopulation
        });


        // Update food amount
        if (ShouldTick(FoodProductionTick))
        {
            Mechanics.ProceedFood(ref FoodAmount, NormalizedRate(FoodProductionRate, FoodProductionTick), FoodProductionModifier);
        }

        // Proceed game loop
        if (IsNewYear())
        {
            Mechanics.ProceedNewYear(mYear, ref mChildrenPool, NumberOfChildrenPool, ref mAdultPool, MaximumPopulation, ChildrenPopulation, ref FoodAmount);


            if (mChildrenPool[mYear % NumberOfChildrenPool].children > 0)
            {
                EventManager.TriggerEvent("population_update", new object[] {
                    mAdultPool.TotalMales, mAdultPool.TotalFemales, ChildrenPopulation, MaximumPopulation
                });
            }
        }
    }
Beispiel #23
0
 public MechanicInfo GetMechanic(int id)
 {
     if (Mechanics.ContainsKey(id))
     {
         return(Mechanics[id]);
     }
     return(null);
 }
Beispiel #24
0
 public int GetMechanicCount(int generatorId)
 {
     if (Mechanics.ContainsKey(generatorId))
     {
         return(Mechanics[generatorId].Count);
     }
     return(0);
 }
 // Start is called before the first frame update
 void Start()
 {
     FindObjectOfType <AudioMnager>(true).SetAudio();
     mechanics = GameObject.FindGameObjectWithTag("Player").GetComponent <Mechanics>();
     player    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStats>();
     inventary = Inventary.inventary;
     SetEnemyHealth();
 }
Beispiel #26
0
    private void Awake()
    {
        state     = GetComponent <State>();
        mechanics = GetComponent <Mechanics>();
        command   = GetComponent <Command>();

        otherState  = state.otherState;
        otherPlayer = state.otherPlayer;
    }
Beispiel #27
0
        void scene_EntityAdded(Entity e)
        {
            var ge = e as Map.GameEntity;

            if (ge != null)
            {
                Mechanics.OnEntityAdded(ge);
            }
        }
 public void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("More than one instance of Inventory found!");
         return;
     }
     instance = this;
 }
Beispiel #29
0
        // Use this for initialization
        new void Start()
        {
            GetComponent <ParticleSystem>().Stop();             // Stop the animation so it doesn't play until the soldier collides with it
            m_GameManager      = GameObject.FindWithTag("GameController");
            m_ManagerMechanics = m_GameManager.GetComponent <Mechanics> ();
            m_Parent           = transform.parent.gameObject;

            m_ManagerMechanics.AddRespawnableObstacle(gameObject);              //Adds the parent object to the list of gameObjects to be reactivated on respawn
        }
Beispiel #30
0
 public static void Main()
 {
     Mechanics.SomeMethod();
     GenericException.Go();
     OneStatementDemo.Go();
     CodeContracts.Go();
     //UnhandledException.Go();
     ConstrainedExecutionRegion.Go();
 }