示例#1
0
        static void Main(string[] args)
        {
            int[] numbers = new int[] { 1, 5, 0, 4, -9, 4, -12, 7, -12, 3, -2, 5 };

            Console.WriteLine(string.Join(" ", numbers));

            OpArray oa = new OpArray(ref numbers);

            Edits[] ed = new Edits[]
            {
                oa.ConvertNegativeToNull,
                oa.SortToUp,
                oa.DoubleElementsToFront
            };

            Calcs[] ca = new Calcs[]
            {
                oa.CountNegativeNumbers,
                oa.CountSimpleNumbers,
                oa.SumAll
            };

            Menu[] m = new Menu[]
            {
                oa.Menu,
                oa.MenuCalc,
                oa.MenuEdit
            };



            m[0]();

            int cat = Convert.ToInt32(Console.ReadLine());

            m[cat]();

            int sub = Convert.ToInt32(Console.ReadLine());

            switch (cat)
            {
            case 1:
                Console.WriteLine(ca[sub - 1]());
                break;

            case 2:
                ed[sub - 1]();
                Console.WriteLine(string.Join(" ", oa.GetNumbers()));
                break;

            default:
                break;
            }
        }
示例#2
0
 public void ReCalcSkills(Character ThisToon)
 {
     // THIS IS INCOMPLETE, FINISH AFTER SKILL PROFICIENCIES FORM
     // int stat = 0;
     // int modifier = 0;
     //ThisToon.SkillsList["Athletics"] = ThisToon.Attributes["Strength"];
     ThisToon.SetSkill(ThisToon, "Athletics", ThisToon.StrMod);
     ThisToon.SetSkill(ThisToon, "Acrobatics", Calcs.CalcMod(ThisToon.Attributes["Dexterity"]));
     ThisToon.SetSkill(ThisToon, "Sleight of Hand", Calcs.CalcMod(ThisToon.Attributes["Dexterity"]));
     ThisToon.SetSkill(ThisToon, "Stealth", Calcs.CalcMod(ThisToon.Attributes["Dexterity"]));
     ThisToon.SetSkill(ThisToon, "Arcana", Calcs.CalcMod(ThisToon.Attributes["Intelligence"]));
     ThisToon.SetSkill(ThisToon, "History", Calcs.CalcMod(ThisToon.Attributes["Intelligence"]));
     ThisToon.SetSkill(ThisToon, "Investigation", Calcs.CalcMod(ThisToon.Attributes["Intelligence"]));
     ThisToon.SetSkill(ThisToon, "Nature", Calcs.CalcMod(ThisToon.Attributes["Intelligence"]));
     ThisToon.SetSkill(ThisToon, "Religion", Calcs.CalcMod(ThisToon.Attributes["Intelligence"]));
     ThisToon.SetSkill(ThisToon, "Animal Handling", Calcs.CalcMod(ThisToon.Attributes["Wisdom"]));
     ThisToon.SetSkill(ThisToon, "Insight", Calcs.CalcMod(ThisToon.Attributes["Wisdom"]));
     ThisToon.SetSkill(ThisToon, "Medicine", Calcs.CalcMod(ThisToon.Attributes["Wisdom"]));
     ThisToon.SetSkill(ThisToon, "Perception", Calcs.CalcMod(ThisToon.Attributes["Wisdom"]));
     ThisToon.SetSkill(ThisToon, "Survival", Calcs.CalcMod(ThisToon.Attributes["Wisdom"]));
     ThisToon.SetSkill(ThisToon, "Deception", Calcs.CalcMod(ThisToon.Attributes["Charisma"]));
     ThisToon.SetSkill(ThisToon, "Intimidation", Calcs.CalcMod(ThisToon.Attributes["Charisma"]));
     ThisToon.SetSkill(ThisToon, "Performance", Calcs.CalcMod(ThisToon.Attributes["Charisma"]));
     ThisToon.SetSkill(ThisToon, "Persuasion", Calcs.CalcMod(ThisToon.Attributes["Charisma"]));
     CalcSkillProficiency(ThisToon);
 }
示例#3
0
 public void SetAttribute(Character ThisToon, string AttName, int AttValue)
 {
     if (ThisToon.Attributes.ContainsKey(AttName))
     {
         ThisToon.Attributes[AttName] = AttValue;
         if (ThisToon.AttributeMods.ContainsKey(AttName))
         {
             ThisToon.AttributeMods[AttName] = Calcs.CalcMod(AttValue);
         }
         else
         {
             ThisToon.AttributeMods.Add(AttName, AttValue);
         }
     }
     else
     {
         ThisToon.Attributes.Add(AttName, AttValue);
         if (ThisToon.AttributeMods.ContainsKey(AttName))
         {
             ThisToon.AttributeMods[AttName] = Calcs.CalcMod(AttValue);
         }
         else
         {
             ThisToon.AttributeMods.Add(AttName, AttValue);
         }
     }
 }
示例#4
0
        public override void DoFollow(object sender = null, System.Timers.ElapsedEventArgs e = null)
        {
            if (_summon.CantMove())
            {
                return;
            }

            double dis = Calcs.CalculateDistance(_summon, _summon.Owner, true);

            if (!(dis > 120))
            {
                return;
            }

            if ((_lastOwnerX == _summon.Owner.X) || (_lastOwnerY == _summon.Owner.Y) || (_lastOwnerZ == _summon.Owner.Z))
            {
                return;
            }

            Character.MoveTo(_summon.Owner.X, _summon.Owner.Y, _summon.Owner.Z);

            _lastOwnerX = _summon.Owner.X;
            _lastOwnerY = _summon.Owner.Y;
            _lastOwnerZ = _summon.Owner.Z;
        }
示例#5
0
        PairedBench vMulPerf(int samples, long cycles)
        {
            var lhs1 = RVec <double>(samples);
            var rhs1 = RVec <double>(samples);
            var dst1 = RowVectors.blockalloc <double>(samples);

            var sw1 = Time.stopwatch(true);

            for (var i = 0; i < cycles; i++)
            {
                Calcs.mul(lhs1, rhs1, dst1.Unblocked);
            }
            var time1 = BenchmarkRecord.Define(cycles, Time.snapshot(sw1), "gmath");

            var lhs2 = lhs1.Replicate();
            var rhs2 = rhs1.Replicate();
            var dst2 = dst1.Replicate();

            var sw2 = Time.stopwatch(true);

            for (var i = 0; i < cycles; i++)
            {
                mkl.mul(lhs2, rhs2, ref dst2);
            }
            var time2 = BenchmarkRecord.Define(cycles, Time.snapshot(sw2), "mkl");

            return(time1, time2);
        }
示例#6
0
        private void ValidateSpawnLocation()
        {
            if (Character.CantMove())
            {
                return;
            }

            switch (_moveHome)
            {
            case 1:
                double dis = Calcs.CalculateDistance(Character.X, Character.Y, Character.Z, Character.SpawnX, Character.SpawnZ, Character.SpawnZ, true);
                if (dis > 100)
                {
                    _moveHome = 2;
                    Character.MoveTo(Character.SpawnX, Character.SpawnY, Character.SpawnZ);
                }
                else
                {
                    _moveHome = 3;
                }
                break;

            case 3:
                if (AttackMove != null)
                {
                    AttackMove.Enabled = false;
                }

                break;
            }
        }
        public override void RunImpl()
        {
            L2Player player = _client.CurrentPlayer;

            if (player.TradeState != 0)
            {
                player.SendSystemMessage(SystemMessage.SystemMessageId.AlreadyTrading);
                player.SendActionFailed();
                return;
            }

            if (player.ObjId == _targetId)
            {
                player.SendSystemMessage(SystemMessage.SystemMessageId.CannotUseOnYourself);
                player.SendActionFailed();
                return;
            }

            if (player.EnchantState != 0)
            {
                player.SendActionFailed();
                return;
            }

            if (!(player.Target is L2Player))
            {
                player.SendSystemMessage(SystemMessage.SystemMessageId.TargetIsIncorrect);
                player.SendActionFailed();
                return;
            }

            L2Player target = (L2Player)player.Target;

            if (target.TradeState != 0)
            {
                player.SendPacket(new SystemMessage(SystemMessage.SystemMessageId.S1AlreadyTrading).AddPlayerName(target.Name));
                player.SendActionFailed();
                return;
            }

            if (target.PartyState == 1)
            {
                player.SendPacket(new SystemMessage(SystemMessage.SystemMessageId.S1IsBusyTryLater).AddPlayerName(target.Name));
                player.SendActionFailed();
                return;
            }

            if (!Calcs.CheckIfInRange(150, player, target, true))
            {
                player.SendActionFailed();
                return;
            }

            player.SendPacket(new SystemMessage(SystemMessage.SystemMessageId.RequestS1ForTrade).AddPlayerName(target.Name));
            target.Requester = player;
            player.Requester = target;
            target.SendPacket(new SendTradeRequest(player.ObjId));
            target.TradeState = 2; // жмакает ответ
            player.TradeState = 1; // запросил
        }
示例#8
0
        public override void onAction(L2Player player)
        {
            double dis = Calcs.calculateDistance(this, player, true);

            player.sendMessage(asString() + " dis " + (int)dis);
            if (dis < 80)
            {
                foreach (L2Object o in knownObjects.Values)
                {
                    if (o is L2Player)
                    {
                        o.sendPacket(new GetItem(player.ObjID, ObjID, X, Y, Z));
                        o.sendPacket(new DeleteObject(ObjID));
                    }
                }

                player.onPickUp(this);

                L2World.Instance.UnrealiseEntry(this, true);
            }
            else
            {
                player.tryMoveTo(X, Y, Z);
            }
        }
示例#9
0
        private void BtnRerollStats_Click(object sender, EventArgs e)
        {
            Calcs calcs = new Calcs();

            int[] RollArray = calcs.RollArray();
            lblDisplayRolls.Text = "Your rolls are - " + RollArray[0] + " , " + RollArray[1] + " , " + RollArray[2] + " , " + RollArray[3] + " , " + RollArray[4] + " , " + RollArray[5];
        }
示例#10
0
        private void ValidateSpawnLocation()
        {
            if (character.cantMove())
            {
                return;
            }

            switch (MoveHome)
            {
            case 1:
                double dis = Calcs.calculateDistance(character.X, character.Y, character.Z, character.SpawnX, character.SpawnZ, character.SpawnZ, true);
                if (dis > 100)
                {
                    MoveHome = 2;
                    character.MoveTo(character.SpawnX, character.SpawnY, character.SpawnZ);
                }
                else
                {
                    MoveHome = 3;
                }
                break;

            case 3:
                if (attackMove != null)
                {
                    attackMove.Enabled = false;
                }

                break;
            }
        }
示例#11
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (Calcs.Count > 0)
            {
                string nomeFile = $"calc{DateTime.Today.ToString("ddMMyy")}{DateTime.Now.ToString("HHmmss")}.txt";

                if (File.Exists(nomeFile))
                {
                    File.Delete(nomeFile);
                }

                using (StreamWriter sw = File.CreateText(nomeFile))
                {
                    foreach (Calculation calcolo in Calcs)
                    {
                        sw.WriteLine($"HP: {calcolo.HP}");

                        foreach (var lista in calcolo.ListAttackRolls)
                        {
                            sw.Write("(");

                            for (int i = 0, len = lista.Count, commalen = len - 1; i < len; i++)
                            {
                                sw.Write($"{lista.ElementAt(i)}");

                                if (i < commalen)
                                {
                                    sw.Write(", ");
                                }
                            }

                            sw.WriteLine(")");
                        }

                        sw.WriteLine($"KO {calcolo.KOcounter}/{calcolo.Total} ({calcolo.SimplifiedKOcounter}/{calcolo.SimplifiedTotal}), {calcolo.KOpercentage}%\n");
                    }
                }

                Calcs.Clear();

                ViewModel.CalcsInMemory = Calcs.Count;

                DidPrint = true;

                string       text    = $"Nome del file: {nomeFile}";
                const string caption = "Esportazione eseguita con successo";
                _ = MessageBox.Show(text, caption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
            }
            else
            {
                const string text    = "Prima fai un calcolo";
                const string caption = "Ancora niente da esportare";
                _ = MessageBox.Show(text, caption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
            }
        }
示例#12
0
 static void Main()
 {
     Console.WriteLine(Calcs.Max(1, 5.5, -3, 5, 6, 1, 1, 12.0, 12.1, 0, -9.9));
     Console.WriteLine(Calcs.Min(1, 5.5, -3, 5, 6, 1, 1, 12.0, 12.1, 0, -9.9));
     Console.WriteLine(Calcs.Sum(1, 5.5, -3, 5, 6, 1, 1, 12.0, 12.1, 0, -9.9));
     Console.WriteLine(Calcs.Product(1, 0.5, -3, 5, 6, 1, 0.1, 12.0, 12.1, 0.5, -9.9));
     Console.WriteLine(Calcs.Average(1, 5.5, -3, 5, 6, 1, 1, 12.0, 12.1, 0, -9.9));
 }
示例#13
0
        public SortedList <int, L2Object> getAffectedTargets(L2Character actor)
        {
            SortedList <int, L2Object> targets = new SortedList <int, L2Object>();

            switch (affect_scope)
            {
            case TSkillScope.single:
            {
                switch (target_type)
                {
                case TSkillTarget.self:
                    targets.Add(actor.ObjID, actor);
                    break;

                case TSkillTarget.friend:
                case TSkillTarget.enemy:
                case TSkillTarget.any:
                case TSkillTarget.target:
                    if (actor.CurrentTarget != null)
                    {
                        targets.Add(actor.CurrentTarget.ObjID, actor.CurrentTarget);
                    }
                    break;

                case TSkillTarget.master:
                    if (actor is L2Summon)
                    {
                        targets.Add(((L2Summon)actor).Owner.ObjID, ((L2Summon)actor).Owner);
                    }
                    break;

                case TSkillTarget.unlockable:
                {
                    if (actor.CurrentTarget != null && actor.CurrentTarget is L2Door)
                    {
                        targets.Add(actor.CurrentTarget.ObjID, actor.CurrentTarget);
                    }
                }
                break;
                }
            }
            break;

            case TSkillScope.party:
                L2Character[] members = actor.getPartyCharacters();
                foreach (L2Character member in members)
                {
                    double dis = Calcs.calculateDistance(actor, member, true);
                    if (dis < cast_range)
                    {
                        targets.Add(member.ObjID, member);
                    }
                }
                break;
            }

            return(targets);
        }
示例#14
0
    public int RollHP(String ClassName)
    {
        int Result;

        if (ClassName == "Barbarian")
        {
            Result = Calcs.RollDice(12);
        }
        else if (ClassName == "Bard")
        {
            Result = Calcs.RollDice(8);
        }
        else if (ClassName == "Cleric")
        {
            Result = Calcs.RollDice(8);
        }
        else if (ClassName == "Druid")
        {
            Result = Calcs.RollDice(8);
        }
        else if (ClassName == "Fighter")
        {
            Result = Calcs.RollDice(10);
        }
        else if (ClassName == "Monk")
        {
            Result = Calcs.RollDice(8);
        }
        else if (ClassName == "Paladin")
        {
            Result = Calcs.RollDice(10);
        }
        else if (ClassName == "Ranger")
        {
            Result = Calcs.RollDice(10);
        }
        else if (ClassName == "Rogue")
        {
            Result = Calcs.RollDice(8);
        }
        else if (ClassName == "Sorcerer")
        {
            Result = Calcs.RollDice(6);
        }
        else if (ClassName == "Warlock")
        {
            Result = Calcs.RollDice(8);
        }
        else if (ClassName == "Wizard")
        {
            Result = Calcs.RollDice(6);
        }
        else
        {
            Result = 0;
        }
        return(Result);
    }
        public override void run()
        {
            L2Player player = Client.CurrentPlayer;

            if (player.TradeState != 2)
            {
                player.sendMessage("Stupid.");
                response = 0;
            }

            if (player.requester == null)
            {
                player.sendMessage("Your trade requestor has logged off.");
                player.sendActionFailed();
                player.TradeState = 0;
                return;
            }

            if (response != 0 && player.requester.TradeState != 1)
            {
                response = 0;
            }

            if (response != 0 && player.EnchantState != 0)
            {
                response = 0;
            }

            if (response != 0 && !Calcs.checkIfInRange(150, player, player.requester, true))
            {
                response = 0;
            }

            if (response != 0 && player.InstanceID != -1 && player.InstanceID != player.requester.InstanceID)
            {
                response = 0;
            }

            switch (response)
            {
            case 0:
                player.TradeState           = 0;
                player.requester.TradeState = 0;
                player.requester.sendPacket(new SystemMessage(119).addPlayerName(player.Name));    //$c1 has denied your request to trade.
                player.requester.requester = null;
                player.requester           = null;
                break;

            case 1:
                player.requester.sendPacket(new SystemMessage(120).addPlayerName(player.Name));    //You begin trading with $c1.
                player.sendPacket(new SystemMessage(120).addPlayerName(player.requester.Name));    //You begin trading with $c1.
                player.TradeState           = 3;
                player.requester.TradeState = 3;
                player.sendPacket(new TradeStart(player));
                player.requester.sendPacket(new TradeStart(player.requester));
                break;
            }
        }
示例#16
0
        public void CalcTotalTaxTests(double subTotal, double expected)
        {
            //return subTotal * rate;
            double result = Calcs.CalcTotalTax(subTotal);

            expected = Math.Round(expected, 4);
            result   = Math.Round(result, 4);
            Assert.Equal(expected, result);
        }
示例#17
0
        public void Sum_ShouldCalcAndReturnSameValue(int a, int b, int expectedResult)
        {
            // arrange
            // Act
            int actualResult = Calcs.Sum(a, b);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
示例#18
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;

                if (player.TradeState != 2)
                {
                    player.SendMessageAsync("Stupid.");
                    _response = 0;
                }

                if (player.Requester == null)
                {
                    player.SendMessageAsync("Your trade requestor has logged off.");
                    player.SendActionFailedAsync();
                    player.TradeState = 0;
                    return;
                }

                if ((_response != 0) && (player.Requester.TradeState != 1))
                {
                    _response = 0;
                }

                if ((_response != 0) && (player.EnchantState != 0))
                {
                    _response = 0;
                }

                if ((_response != 0) && !Calcs.CheckIfInRange(150, player, player.Requester, true))
                {
                    _response = 0;
                }

                switch (_response)
                {
                case 0:
                    player.TradeState           = 0;
                    player.Requester.TradeState = 0;
                    player.Requester.SendPacketAsync(new SystemMessage(SystemMessageId.S1DeniedTradeRequest).AddPlayerName(player.Name));
                    player.Requester.Requester = null;
                    player.Requester           = null;
                    break;

                case 1:
                    player.Requester.SendPacketAsync(new SystemMessage(SystemMessageId.BeginTradeWithS1).AddPlayerName(player.Name));
                    player.SendPacketAsync(new SystemMessage(SystemMessageId.BeginTradeWithS1).AddPlayerName(player.Requester.Name));
                    player.TradeState           = 3;
                    player.Requester.TradeState = 3;
                    player.SendPacketAsync(new TradeStart(player));
                    player.Requester.SendPacketAsync(new TradeStart(player.Requester));
                    break;
                }
            });
        }
示例#19
0
        public void Sum_ShouldCalcAndReturnAnInteger()
        {
            // arrange
            int a = 4, b = 5;
            // Act
            int actualResult = Calcs.Sum(a, b);

            // Assert
            Assert.IsNotNull(actualResult);
        }
示例#20
0
        public static void Run()
        {
            while (true)
            {
                Thread.Sleep(15);

                if (OffsetStruct.LocalPlayer.BaseStruct.Health < 1 ||
                    !Verification.IsWindowFocused(PreparationProcess.Handle) ||
                    !ConfigStruct.Wallbeeper.Enabled)
                {
                    continue;
                }

                var maxPlayers = OffsetStruct.ClientState.BaseStruct.MaxPlayers;
                var entities   = Memory.ReadMemory((int)OffsetStruct.Base.Client + Offsets.dwEntityList, maxPlayers * 0x10);

                for (int i = 0; i < maxPlayers; i++)
                {
                    var currentEntity       = Calcs.GetInt(entities, i * 0x10);
                    var currentEntityStruct = Memory.ReadMemory <OffsetStruct.Enemy_t>(currentEntity);

                    if (currentEntityStruct.Team == OffsetStruct.LocalPlayer.BaseStruct.Team ||
                        currentEntityStruct.Health < 1 ||
                        currentEntityStruct.Dormant ||
                        currentEntityStruct.Spotted)
                    {
                        continue;
                    }

                    var bonePosition = Calcs.GetBonePos(currentEntity, 5);

                    if (bonePosition == Vector3.Zero)
                    {
                        continue;
                    }

                    var destination = Calcs.CalcAngle(OffsetStruct.LocalPlayer.BaseStruct.Position, bonePosition, OffsetStruct.LocalPlayer.BaseStruct.AimPunch, OffsetStruct.LocalPlayer.BaseStruct.VecView, 0f, 0f);

                    if (destination == Vector3.Zero)
                    {
                        continue;
                    }

                    var distance = Calcs.GetDistance3D(destination, OffsetStruct.ClientState.BaseStruct.ViewAngles);

                    if (distance > 1.2f)
                    {
                        continue;
                    }

                    Console.Beep(1000, 300);
                    Thread.Sleep(3000);
                }
            }
        }
示例#21
0
文件: Skill.cs 项目: temukaa/develop
        public SortedList <int, L2Object> GetAffectedTargets(L2Character actor)
        {
            SortedList <int, L2Object> targets = new SortedList <int, L2Object>();

            switch (AffectScope)
            {
            case SkillScope.Single:
            {
                switch (TargetType)
                {
                case SkillTarget.Self:
                    targets.Add(actor.ObjId, actor);
                    break;

                case SkillTarget.Friend:
                case SkillTarget.Enemy:
                case SkillTarget.Any:
                case SkillTarget.Target:
                    if (actor.CurrentTarget != null)
                    {
                        targets.Add(actor.CurrentTarget.ObjId, actor.CurrentTarget);
                    }
                    break;

                case SkillTarget.Master:
                    if (actor is L2Summon)
                    {
                        targets.Add(((L2Summon)actor).Owner.ObjId, ((L2Summon)actor).Owner);
                    }
                    break;

                case SkillTarget.Unlockable:
                {
                    if (actor.CurrentTarget is L2Door)
                    {
                        targets.Add(actor.CurrentTarget.ObjId, actor.CurrentTarget);
                    }
                }
                break;
                }
            }

            break;

            case SkillScope.Party:
                L2Character[] members = actor.GetPartyCharacters();
                targets = members.Where(member => Calcs.CalculateDistance(actor, member, true) < CastRange).ToSortedList(member => member.ObjId, member => (L2Object)member);
                break;
            }

            return(targets);
        }
示例#22
0
        public void vMulF32()
        {
            var lhs  = RVec <float>();
            var rhs  = RVec <float>();
            var dst1 = RowVectors.blockalloc <float>(lhs.Length);

            mkl.mul(lhs, rhs, ref dst1);

            var dst2 = lhs.Replicate();

            Calcs.mul(lhs, rhs, dst2.Unblocked);
            Claim.require(dst1 == dst2);
        }
示例#23
0
        public void Substract_ShouldCalcAndReturnSameValue(int a, int b, int expected)
        {
            //Arrange
            //int a = 4
            //int b = 1
            //expected = 3

            //Act
            int actual = Calcs.Substract(a, b);

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#24
0
文件: tvml_add.cs 项目: 0xCM/z0
        public void vaddF64()
        {
            var lhs  = RVec <double>();
            var rhs  = RVec <double>();
            var dst1 = RowVectors.blockalloc <double>(lhs.Length);

            mkl.add(lhs, rhs, ref dst1);

            var dst2 = lhs.Replicate();

            Calcs.add(lhs, rhs, dst2.Unblocked);
            Claim.require(dst1 == dst2);
        }
示例#25
0
        public void vMulF64()
        {
            var lhs  = Random.VectorBlock <N256, double>();
            var rhs  = Random.VectorBlock <N256, double>();
            var dst1 = RowVectors.blockalloc <N256, double>();

            mkl.mul(lhs, rhs, ref dst1);

            var dst2 = lhs.Replicate();

            Calcs.mul(lhs.Unsized, rhs.Unsized, dst2.Unsized);
            Claim.require(dst1 == dst2);
        }
示例#26
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!handled)
        {
            Enemy enemy = collision.gameObject.GetComponent <Enemy>();

            if (enemy)
            {
                print(enemy.health);

                if (collision.collider.tag == "critical")
                {
                    float dealtDamage = Calcs.damage(damage, true, false, false, false);
                    enemy.health -= dealtDamage;

                    TextMesh textcomp = floatingText.GetComponent <TextMesh>();
                    textcomp.text  = dealtDamage.ToString();
                    textcomp.color = Color.red;
                    Instantiate(floatingText, transform.position, Quaternion.identity);
                    enemy.flash(Color.red);

                    //ouch
                    handled = true;
                }
                else if (collision.collider.tag == "armoured")
                {
                    float dealtDamage = Calcs.damage(damage, false, true, false, false);
                    enemy.health -= dealtDamage;

                    TextMesh textcomp = floatingText.GetComponent <TextMesh>();
                    textcomp.text  = dealtDamage.ToString();
                    textcomp.color = Color.yellow;
                    Instantiate(floatingText, transform.position, Quaternion.identity);
                    enemy.flash(Color.yellow);

                    //nope
                    handled = true;
                }

                enemy.checkDead();
                print(enemy.health);
            }

            if (!rebound)
            {
                Destroy(gameObject);
            }
        }
    }
        public void Multiply_ShoulCalAndReturnSameValue()
        {
            //Arrange
            int a      = 6;
            int b      = 10;
            int expect = 50;

            //Act

            int actual = Calcs.Multiply(a, b);

            //Assert

            Assert.AreEqual(expect, actual);
        }
        public void Sum_ShouldCalcAndReturnSameValue()
        {
            //Arrange

            int a        = 4;
            int b        = 4;
            int expected = 8;

            //Act

            int actual = Calcs.Sum(a, b);

            //Assert

            Assert.AreEqual(expected, actual);
        }
示例#29
0
    public void SetAttMods(Character ThisToon)
    {
        AttributeMods.Add("Strength", Calcs.CalcMod(Strength));
        AttributeMods.Add("Dexterity", Calcs.CalcMod(Dexterity));
        AttributeMods.Add("Constitution", Calcs.CalcMod(Constitution));
        AttributeMods.Add("Intelligence", Calcs.CalcMod(Intelligence));
        AttributeMods.Add("Wisdom", Calcs.CalcMod(Wisdom));
        AttributeMods.Add("Charisma", Calcs.CalcMod(Charisma));

        ThisToon.StrMod = Calcs.CalcMod(Strength);
        ThisToon.DexMod = Calcs.CalcMod(Dexterity);
        ThisToon.ConMod = Calcs.CalcMod(Constitution);
        ThisToon.IntMod = Calcs.CalcMod(Intelligence);
        ThisToon.WisMod = Calcs.CalcMod(Wisdom);
        ThisToon.ChaMod = Calcs.CalcMod(Charisma);
    }
示例#30
0
        private void AttackMoveTask(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (_player.IsAttacking())
            {
                return;
            }

            if (_player.Target == null)
            {
                AttackMove.Enabled = false;
                return;
            }

            double dis = Calcs.CalculateDistance(_player, Character.Target, true);

            if (dis < 80)
            {
                L2Character target = _player.Target;
                if (!target.Dead)
                {
                    _player.DoAttack(target);
                }
            }
            else
            {
                if (_player.CantMove())
                {
                    return;
                }

                if ((_lastx != _player.Target.X) || (_lasty != _player.Target.Y) || (_lastz != _player.Target.Z))
                {
                    _moveTarget = 0;
                }

                if (_moveTarget != 0)
                {
                    return;
                }

                _player.MoveTo(_player.Target.X, _player.Target.Y, _player.Target.Z);
                _moveTarget = 1;
                _lastx      = Character.Target.X;
                _lasty      = Character.Target.Y;
                _lastz      = Character.Target.Z;
            }
        }