Example #1
0
    // On new instance, this will fired, which will setup the dictionary
    protected void Initiate(int numberOfMultipliers)
    {
        // Ensure you have an active instance of the dictionary
        if (Multipliers == null)
        {
            Multipliers = new Dictionary <string, float>();
        }

        // Ensurance
        if (numberOfMultipliers > 0)
        {
            MultCount = numberOfMultipliers;
            for (int x = 1; x <= numberOfMultipliers; x++)
            {
                if (!Multipliers.ContainsKey("Mult" + x))
                {
                    Multipliers.Add("Mult" + x, 0);
                }
            }
        }
        else
        {
            throw new ArgumentOutOfRangeException();
        }
    }
Example #2
0
 private void Recalc()
 {
     Value = components
             .Select(s => new ComboStat(s, AdditiveFuckYou))
             .Aggregate(this.Base * (1 + AdditiveMultipliers), (a, b) => a + b.Value)
             * Multipliers.Aggregate(1.0, (a, b) => a * b);
 }
Example #3
0
    // Use this for initialization
    void Start()
    {
        player        = GetComponent <Player>();
        multi         = GetComponent <Multipliers>();
        userInterface = GameObject.Find("Main UI").GetComponent <UI>();
        className     = player.getClassName();
        switch (className)
        {
        case "General":
            abillityCooldown = 30;
            buyMulti         = 0.9f;
            upgradeMulti     = 1;
            break;

        case "Scientist":
            abillityCooldown = 15;
            buyMulti         = 1;
            upgradeMulti     = 0.9f;
            break;

        case "Engineer":
            abillityCooldown = 25;
            buyMulti         = 1;
            upgradeMulti     = 1;
            break;
        }
    }
Example #4
0
        //creates and returns a new generation of values based on the 4 highest scores of the "parent"
        protected List <Multipliers> Generate_New_Generation(List <Multipliers> Mult_Values)//syntax of calling this should be Mult_Values = Generate_New_Generation(Mult_Values);
        {
            List <Multipliers> Children = new List <Multipliers>();
            Multipliers        Temp     = new Multipliers();

            //sort the Mult_Values by highest score
            for (int Q = 0; Q < Mult_Values.Count; Q++)
            {
                for (int A = Q + 1; A < Mult_Values.Count; A++)
                {
                    if (Mult_Values[Q].score < Mult_Values[A].score)
                    {
                        Temp           = new Multipliers(Mult_Values[Q]);
                        Mult_Values[Q] = new Multipliers(Mult_Values[A]);
                        Mult_Values[A] = new Multipliers(Temp);
                    }
                }
            }//tested, works!

            //A is 0, B is 1, C is 2, D is 3 (elements)
            //So pairing will go AB CD AC BD so that each parent is used twice
            //element wise, the pairs go as 01 23 02 13
            for (int Q = 0; Q < 8; Q++)
            {
                Children.Add(new Multipliers());
            }
            //child 1 and 2, pairing with AB
            for (int Q = 0; Q < 2; Q++)
            {
                Children[Q].HoleMultiplier      = setChildValue(Mult_Values[0].HoleMultiplier, Mult_Values[1].HoleMultiplier);
                Children[Q].LinesMultiplier     = setChildValue(Mult_Values[0].LinesMultiplier, Mult_Values[1].LinesMultiplier);
                Children[Q].BumpinessMultiplier = setChildValue(Mult_Values[0].BumpinessMultiplier, Mult_Values[1].BumpinessMultiplier);
                Children[Q].HeightMultiplier    = setChildValue(Mult_Values[0].HeightMultiplier, Mult_Values[1].HeightMultiplier);
            }
            //child 3 and 4, pairing with CD
            for (int Q = 2; Q < 4; Q++)
            {
                Children[Q].HoleMultiplier      = setChildValue(Mult_Values[2].HoleMultiplier, Mult_Values[3].HoleMultiplier);
                Children[Q].LinesMultiplier     = setChildValue(Mult_Values[2].LinesMultiplier, Mult_Values[3].LinesMultiplier);
                Children[Q].BumpinessMultiplier = setChildValue(Mult_Values[2].BumpinessMultiplier, Mult_Values[3].BumpinessMultiplier);
                Children[Q].HeightMultiplier    = setChildValue(Mult_Values[2].HeightMultiplier, Mult_Values[3].HeightMultiplier);
            }
            //child 5 and 6, pairing with AC
            for (int Q = 4; Q < 6; Q++)
            {
                Children[Q].HoleMultiplier      = setChildValue(Mult_Values[0].HoleMultiplier, Mult_Values[2].HoleMultiplier);
                Children[Q].LinesMultiplier     = setChildValue(Mult_Values[0].LinesMultiplier, Mult_Values[2].LinesMultiplier);
                Children[Q].BumpinessMultiplier = setChildValue(Mult_Values[0].BumpinessMultiplier, Mult_Values[2].BumpinessMultiplier);
                Children[Q].HeightMultiplier    = setChildValue(Mult_Values[0].HeightMultiplier, Mult_Values[2].HeightMultiplier);
            }
            //child 7 and 8, pairing with BD
            for (int Q = 4; Q < 6; Q++)
            {
                Children[Q].HoleMultiplier      = setChildValue(Mult_Values[1].HoleMultiplier, Mult_Values[3].HoleMultiplier);
                Children[Q].LinesMultiplier     = setChildValue(Mult_Values[1].LinesMultiplier, Mult_Values[3].LinesMultiplier);
                Children[Q].BumpinessMultiplier = setChildValue(Mult_Values[1].BumpinessMultiplier, Mult_Values[3].BumpinessMultiplier);
                Children[Q].HeightMultiplier    = setChildValue(Mult_Values[1].HeightMultiplier, Mult_Values[3].HeightMultiplier);
            }
            return(Children);
        }
Example #5
0
 public Multipliers(Multipliers Copy_Class)
 {
     this.BumpinessMultiplier = Copy_Class.BumpinessMultiplier;
     this.HeightMultiplier    = Copy_Class.HeightMultiplier;
     this.HoleMultiplier      = Copy_Class.HoleMultiplier;
     this.LinesMultiplier     = Copy_Class.LinesMultiplier;
     this.score = Copy_Class.score;
 }
Example #6
0
        protected decimal ApplyMultipliers(decimal value)
        {
            foreach (MultiplierModel multiplier in Multipliers.Where(t => t.IsTicked))
            {
                value = value * multiplier.Multiplier;
            }

            return(Math.Min(value, 9999));
        }
Example #7
0
        protected int ApplyMultipliers(int value)
        {
            decimal multipliedValue = value;

            foreach (MultiplierModel multiplier in Multipliers.Where(t => t.IsTicked))
            {
                multipliedValue *= multiplier.Multiplier;
            }

            return(Math.Min(RoundDown(multipliedValue), 9999));
        }
Example #8
0
 private void Start()
 {
     sets  = GameObject.Find("Settings").GetComponent <Settings>();
     audio = GetComponent <AudioSource>();
     gcs   = FindObjectOfType <GameControllerScr>();
     multi = GameObject.Find("Main Camera").GetComponent <Multipliers>();
     selfTower.Add(gcs.AllTowers[(int)selfType]);
     selfTower.Add(gcs.SecondTowers[(int)selfType]);
     selfTower.Add(gcs.ThirdTowers[(int)selfType]);
     GetComponent <SpriteRenderer>().sprite = selfTower[level].Spr;
     InvokeRepeating("SearchTarget", 0, .1f);
 }
Example #9
0
        public void MultiplierTest()
        {
            var(fa1, fa2)   = Read2ColumnFloatsFromFile(F2_1MFile);
            var(mem1, mem2) = (fa1.AsMemory(), fa2.AsMemory());
            Console.WriteLine($"Starting calculations with file: {F2_1MFile}");
            var sw1      = Stopwatch.StartNew();
            var rIntrFma = Multipliers.DotMultiplyIntrinsicWFma(ref mem1, ref mem2);

            sw1.Stop();
            Console.WriteLine($"Intrinsic calculation (Fma) finished in {sw1.Elapsed}. Result is: {rIntrFma}");

            var sw1ptr      = Stopwatch.StartNew();
            var rIntrFmaPtr = Multipliers.DotMultiplyIntrinsicWFmaWSpanPtr(ref mem1, ref mem2);

            sw1ptr.Stop();
            Console.WriteLine($"Intrinsic calculation (FmaWPtr) finished in {sw1ptr.Elapsed}. Result is: {rIntrFmaPtr}");

            var sw2      = Stopwatch.StartNew();
            var rIntrAvx = Multipliers.DotMultiplyIntrinsicWAvx(ref mem1, ref mem2);

            sw2.Stop();
            Console.WriteLine($"Intrinsic calculation (Avx) finished in {sw2.Elapsed}. Result is: {rIntrAvx}");

            var sw2ptr      = Stopwatch.StartNew();
            var rIntrAvxPtr = Multipliers.DotMultiplyIntrinsicWAvxWSpanPtr(ref mem1, ref mem2);

            sw2ptr.Stop();
            Console.WriteLine($"Intrinsic calculation (AvxWPtr) finished in {sw2ptr.Elapsed}. Result is: {rIntrAvxPtr}");

            var sw3   = Stopwatch.StartNew();
            var rClas = Multipliers.DotMultiplyClassic(ref mem1, ref mem2);

            sw3.Stop();
            Console.WriteLine($"Classic calculation finished in {sw3.Elapsed}. Result is: {rClas}");

            var sw3ptr   = Stopwatch.StartNew();
            var rClasPtr = Multipliers.DotMultiplyClassicWPtr(ref mem1, ref mem2);

            sw3ptr.Stop();
            Console.WriteLine($"Classic calculation With Ptr finished in {sw3ptr.Elapsed}. Result is: {rClasPtr}");

            var sw4     = Stopwatch.StartNew();
            var rClasG4 = Multipliers.DotMultiplyClassicGroup4(ref mem1, ref mem2);

            sw4.Stop();
            Console.WriteLine($"Classic calculation Group 4 finished in {sw4.Elapsed}. Result is: {rClasG4}");

            var sw5     = Stopwatch.StartNew();
            var rClasG8 = Multipliers.DotMultiplyClassicGroup8(ref mem1, ref mem2);

            sw4.Stop();
            Console.WriteLine($"Classic calculation Group 8 finished in {sw5.Elapsed}. Result is: {rClasG8}");
        }
Example #10
0
        public void ParallelEfficiencyTest()
        {
            var         capacity   = 2;
            Multipliers multiplier = Multipliers.Usual;

            while (multiplier == Multipliers.Usual)
            {
                multiplier = WhoIsBetter(capacity);
                capacity++;
            }

            Assert.IsTrue(capacity > 15); // capacity can be differ. It depends on PC configuration.
        }
Example #11
0
 // This is the main method to generate the multiplication part.
 public void Generate(int multNumber, int multiplier)
 {
     if (multNumber == 0)
     {
         Multipliers["Mult"] = Source * multiplier;
     }
     else if (Multipliers.ContainsKey("Mult" + multNumber))
     {
         // store the value in the dictionary (this is for reference)
         Multipliers["Mult" + multNumber] = SetMult(multNumber, Source * multiplier);
     }
     else
     {
         throw new NullReferenceException();
     }
 }
        private float GetMultiplierValue(Multipliers multipliers)
        {
            switch (multipliers)
            {
            case Multipliers.Low:
                return(0.75f);

            case Multipliers.Medium:
                return(1.00f);

            case Multipliers.High:
                return(1.25f);
            }

            return(0);
        }
Example #13
0
    void Awake()
    {
        // check for duplicate singleton
        if (me && me != this)
        {
            Debug.LogWarning("duplicate Multipliers");
            enabled = false;
            return;
        }
        me = this;

        // init kills requirements
        for (int i = 0; i < 2; i++)
        {
            killsToNextMul[i] = initKillsRequired;
        }

        au = GetComponents <AudioSource>();
    }
Example #14
0
        private void AddMultiplier(TransitionMultiplierValue item)
        {
            List <TransitionMultiplierValue> Multipliers = this.GetItemExact(
                item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                item.StateClassId, item.Iteration, item.Timestep);

            if (Multipliers == null)
            {
                Multipliers = new List <TransitionMultiplierValue>();

                this.AddItem(item.TransitionGroupId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                             item.StateClassId, item.Iteration, item.Timestep, Multipliers);

                this.m_AllLists.Add(Multipliers);
            }

            Multipliers.Add(item);
            base.SetHasItems();
        }
Example #15
0
 private void Start()
 {
     gcs   = FindObjectOfType <GameControllerScr>();
     multi = GameObject.Find("Main Camera").GetComponent <Multipliers>();
     if (level == 0)
     {
         selfProjectile = gcs.AllProjectiles[selfTower.type];
     }
     else if (level == 1)
     {
         selfProjectile = gcs.SecondProjectiles[selfTower.type];
     }
     else if (level == 2)
     {
         selfProjectile = gcs.ThirdProjectiles[selfTower.type];
     }
     basicDamage = selfProjectile.damage;
     GetComponent <SpriteRenderer>().sprite = selfProjectile.Spr;
 }
Example #16
0
    /// <summary>
    /// trigger match begin (used by button)
    /// </summary>
    public void MatchBegin()
    {
        playing = true;

        // enable/disable objects
        foreach (var go in ingameObjects)
        {
            MenuSetActive(go, true);
        }
        foreach (var go in menuObjects)
        {
            MenuSetActive(go, false);
        }
        playerObject.SetActive(true);

        // start music
        Options.me.music.volume = Options.musicVol;
        if (Options.me.music.volume > 0 && !Options.me.music.isPlaying)
        {
            Options.me.music.Play();
        }
        // reset point-related stuff
        Domination.ResetMe();
        Multipliers.ResetMe();

        // trigger respawn of all existing bots
        foreach (var ss in SSTeam.list)
        {
            var   death = ss.GetComponent <SSDeathAndSpawn>();
            float v     = Random.value;
            if (ss.GetComponent <SSControlPlayer>())
            {
                v = .75f + .25f * v;
            }
            death.Die(true, v);
        }
    }
Example #17
0
    /// <summary>
    /// Die/reset this spaceship.
    /// </summary>
    /// <param name="asReset">whether this was a reset (no explosion, no points)</param>
    /// <param name="delayMultiplier">factor to multiply respawn delay with</param>
    public void Die(bool asReset = false, float delayMultiplier = 1f)
    {
        if (!gameObject.activeSelf)
        {
            // cancel previous respawn timer
            CancelInvoke();
            // respawn after given time
            if (delayMultiplier <= 0)
            {
                BeginSpawn();
            }
            else
            {
                Invoke(nameof(BeginSpawn), respawnDelay * delayMultiplier);
            }
            return;
        }

        // reset health
        health = StartHealth;

        if (!asReset)
        {
            // explode and add points and multiplier kill
            MakeExplosion();
            int mul = 1;
            if (Multipliers.me)
            {
                mul = Multipliers.me.muls[1 - team.team];
            }
            if (Domination.me)
            {
                Domination.Score(1 - team.team, mul);
            }
            if (Multipliers.me)
            {
                Multipliers.AddKill(1 - team.team);
            }
        }

        // reset relevant objects
        if (shield)
        {
            shield.ResetMe();
        }
        foreach (var go in toggles)
        {
            go.SetActive(false);
        }

        // respawn after given time
        if (delayMultiplier <= 0)
        {
            BeginSpawn();
        }
        else
        {
            Invoke(nameof(BeginSpawn), respawnDelay * delayMultiplier);
        }

        // hide object (Invoke will still run)
        gameObject.SetActive(false);
    }
Example #18
0
 public Matrix()
 {
     Multipliers_Rows    = Multipliers.GetLength(0);
     Multipliers_Columns = Multipliers.GetLength(1);
 }
Example #19
0
 public override string ToString()
 {
     return(String.Join(" * ", Multipliers.Select(m => m.ToString())));
 }
Example #20
0
        static void ProcessPacket(int packetid)
        {
            switch (packetid)
            {
            case 0:
                #region entityUpdate
                var entityUpdate = new EntityUpdate(reader);
                if (players.ContainsKey(entityUpdate.guid))
                {
                    entityUpdate.Merge(players[entityUpdate.guid]);
                }
                else
                {
                    players.Add(entityUpdate.guid, entityUpdate);
                }
                if (players[entityUpdate.guid].name == "malox")
                {
                    maloxGuid = entityUpdate.guid;
                    var    x        = players[entityUpdate.guid].position.x - players[personalGuid].position.x;
                    var    y        = players[entityUpdate.guid].position.y - players[personalGuid].position.y;
                    double distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
                    if (distance > 65536 * 40)
                    {
                        var follow = new EntityUpdate {
                            position = players[entityUpdate.guid].position,
                            guid     = personalGuid
                        };
                        follow.Write(writer);
                    }
                    if (entityUpdate.modeTimer < 50)
                    {
                        var shoot = new Shoot()
                        {
                            attacker   = personalGuid,
                            chunkX     = (int)players[personalGuid].position.x / 0x1000000,
                            chunkY     = (int)players[personalGuid].position.y / 0x1000000,
                            position   = players[personalGuid].position,
                            particles  = 1f,
                            mana       = 1f,
                            scale      = 1f,
                            projectile = 0,
                        };
                        shoot.position.x = players[maloxGuid].position.x + (long)(players[maloxGuid].rayHit.x * 0x10000);
                        shoot.position.y = players[maloxGuid].position.y + (long)(players[maloxGuid].rayHit.y * 0x10000);
                        shoot.position.z = players[maloxGuid].position.z + (long)((players[maloxGuid].rayHit.z + 15) * 0x10000);

                        shoot.velocity.z = -40f;

                        //shoot.velocity.x = (float)players[maloxGuid].position.x / 0x10000f + players[maloxGuid].rayHit.x - (float)players[personalGuid].position.x / 0x10000f;
                        //shoot.velocity.y = (float)players[maloxGuid].position.y / 0x10000f + players[maloxGuid].rayHit.y - (float)players[personalGuid].position.y / 0x10000f;


                        //shoot.velocity.z = (float)players[maloxGuid].position.z / 0x10000f + players[maloxGuid].rayHit.z - (float)players[personalGuid].position.z / 0x10000f;
                        int range = 20;
                        shoot.position.x -= (range - 1) / 2 * 0x10000;
                        shoot.position.y -= (range - 1) / 2 * 0x10000;
                        for (int i = 0; i < range; i++)
                        {
                            for (int j = 0; j < range; j++)
                            {
                                shoot.Write(writer);
                                shoot.position.x += 0x10000;
                            }
                            shoot.position.x -= range * 0x10000;
                            shoot.position.y += 0x10000;
                        }
                    }
                }
                break;

                #endregion
            case 2:
                #region complete
                new EntityUpdate()
                {
                    lastHitTime = (int)stopWatch.ElapsedMilliseconds
                }.Write(writer);
                break;

                #endregion
            case 4:
                #region serverupdate
                var serverUpdate = new ServerUpdate(reader);
                foreach (var hit in serverUpdate.hits)
                {
                    if (hit.target == personalGuid)
                    {
                        stopWatch.Restart();
                        players[personalGuid].HP -= hit.damage;
                        var life = new EntityUpdate()
                        {
                            HP = players[personalGuid].HP,
                        };

                        life.Write(writer);
                        if (players[personalGuid].HP <= 0)
                        {
                            life.HP = 1623f;
                            life.Write(writer);
                        }
                    }
                }
                break;

                #endregion
            case 5:
                #region time
                var time = new Time(reader);
                break;

                #endregion
            case 10:
                #region chat
                var chatMessage = new ChatMessage(reader, true);
                if (chatMessage.sender == 0)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write(players[chatMessage.sender].name + ": ");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.WriteLine(chatMessage.message);
                if (chatMessage.message == "!give_me_items")
                {
                    var port = new EntityUpdate {
                        position = players[chatMessage.sender].position,
                        guid     = personalGuid
                    };
                    port.Write(writer);
                    players[personalGuid].position = port.position;

                    var items = new List <Item>();

                    var rng = new Random();
                    for (byte i = 3; i <= 9; i++)
                    {
                        items.Add(new Item()
                        {
                            type     = i,
                            modifier = rng.Next(0x7FFFFFFF),
                            rarity   = 4,
                            level    = (short)players[chatMessage.sender].level
                        });
                    }
                    items[5].material = (byte)rng.Next(11, 12);
                    items[6].material = (byte)rng.Next(11, 12);
                    items.Add(items[6]);
                    byte armorMaterial;
                    switch (players[chatMessage.sender].entityClass)
                    {
                    case 0:         //warrior
                        //items[0].subtype = 0;
                        items[0].material = 1;
                        for (int i = 0; i < 6; i++)
                        {
                            items.Add(new Item()
                            {
                                type     = 3,
                                material = 1,
                                modifier = rng.Next(0x7FFFFFFF),
                                rarity   = 4,
                                level    = (short)players[chatMessage.sender].level
                            });
                        }
                        items[8].subtype  = 1;
                        items[9].subtype  = 2;
                        items[10].subtype = 13;
                        items[11].subtype = 15;
                        items[12].subtype = 16;
                        items[13].subtype = 17;

                        armorMaterial = 1;
                        break;

                    case 1:         //mage
                        items[0].subtype  = 10;
                        items[0].material = 2;
                        for (int i = 0; i < 3; i++)
                        {
                            items.Add(new Item()
                            {
                                type     = 3,
                                material = (byte)rng.Next(11, 12),
                                modifier = rng.Next(0x7FFFFFFF),
                                rarity   = 4,
                                level    = (short)players[chatMessage.sender].level
                            });
                        }

                        items[8].subtype  = 11;
                        items[8].material = 2;
                        items[9].subtype  = 12;
                        items[10].subtype = 12;

                        armorMaterial = 25;
                        break;


                    case 2:         //ranger
                        items[0].subtype  = 6;
                        items[0].material = 2;
                        for (int i = 0; i < 2; i++)
                        {
                            items.Add(new Item()
                            {
                                type     = 3,
                                material = 2,
                                modifier = rng.Next(0x7FFFFFFF),
                                rarity   = 4,
                                level    = (short)players[chatMessage.sender].level
                            });
                        }
                        items[8].subtype = 7;
                        items[9].subtype = 8;

                        armorMaterial = 26;
                        break;

                    case 3:         //rogue
                        items[0].subtype  = 3;
                        items[0].material = 1;
                        for (int i = 0; i < 2; i++)
                        {
                            items.Add(new Item()
                            {
                                type     = 3,
                                material = 1,
                                modifier = rng.Next(0x7FFFFFFF),
                                rarity   = 4,
                                level    = (short)players[chatMessage.sender].level
                            });
                        }
                        items[8].subtype = 4;
                        items[9].subtype = 5;

                        armorMaterial = 27;
                        break;

                    default:
                        goto case 0;
                    }
                    for (int i = 1; i <= 4; i++)
                    {
                        items[i].material = armorMaterial;
                    }

                    foreach (var that in items)
                    {
                        var drop = new EntityAction {
                            type = (int)Database.ActionType.drop,
                            item = that
                        };
                        drop.Write(writer);
                    }

                    //item = new Item {
                    //    type = 3, // 3 = weapon
                    //    rarity = 4, // 4 = legendary
                    //    level = 647,
                    //    material = 1
                    //}
                }
                else if (chatMessage.message == "!come_here")
                {
                    var port = new EntityUpdate {
                        position = players[chatMessage.sender].position,
                        guid     = personalGuid
                    };
                    port.Write(writer);
                }

                break;

                #endregion
            case 15:
                #region mapseed
                var mapSeed = new MapSeed(reader);
                break;

                #endregion
            case 16:
                #region join
                var join = new Join(reader);
                personalGuid = join.guid;

                var playerstats = new EntityUpdate()
                {
                    position      = new LongVector(),
                    rotation      = new FloatVector(),
                    velocity      = new FloatVector(),
                    acceleration  = new FloatVector(),
                    extraVel      = new FloatVector(),
                    viewportPitch = 0,
                    physicsFlags  = 0b00000000_00000000_00000000_00010001,   //17
                    hostility     = 0,
                    entityType    = 0,
                    mode          = 0,
                    modeTimer     = 0,
                    combo         = 0,
                    lastHitTime   = 0,
                    appearance    = new Appearance()
                    {
                        character_size = new FloatVector()
                        {
                            x = 0.9600000381f,
                            y = 0.9600000381f,
                            z = 2.160000086f
                        },
                        head_model      = 1236,
                        hair_model      = 1280,
                        hand_model      = 430,
                        foot_model      = 432,
                        body_model      = 1,
                        tail_model      = -1,
                        shoulder2_model = -1,
                        wings_model     = -1,
                        head_size       = 1.00999999f,
                        body_size       = 1f,
                        hand_size       = 1f,
                        foot_size       = 0.9800000191f,
                        shoulder2_size  = 1f,
                        weapon_size     = 0.9499999881f,
                        tail_size       = 0.8000000119f,
                        shoulder_size   = 1f,
                        wings_size      = 1f,
                        body_offset     = new FloatVector()
                        {
                            z = -5f
                        },
                        head_offset = new FloatVector()
                        {
                            y = 0.5f,
                            z = 5f
                        },
                        hand_offset = new FloatVector()
                        {
                            x = 6f,
                        },
                        foot_offset = new FloatVector()
                        {
                            x = 3f,
                            y = 1f,
                            z = -10.5f
                        },
                        back_offset = new FloatVector()
                        {
                            y = -8f,
                            z = 2f
                        },
                    },
                    entityFlags    = 0b00000000_00000000_00000000_00100000, //64
                    roll           = 0,
                    stun           = 0,
                    slow           = 0,
                    ice            = 0,
                    wind           = 0,
                    showPatchTime  = 0,
                    entityClass    = 2,
                    specialization = 0,
                    charge         = 0,
                    unused24       = new FloatVector(),
                    unused25       = new FloatVector(),
                    rayHit         = new FloatVector(),
                    HP             = 1623f,
                    MP             = 0,
                    block          = 1,
                    multipliers    = new Multipliers()
                    {
                        HP          = 100,
                        attackSpeed = 1,
                        damage      = 1,
                        armor       = 1,
                        resi        = 1,
                    },
                    unused31          = 0,
                    unused32          = 0,
                    level             = 500,
                    XP                = 0,
                    parentOwner       = 0,
                    unused36          = 0,
                    powerBase         = 0,
                    unused38          = 0,
                    unused39          = new IntVector(),
                    spawnPos          = new LongVector(),
                    unused41          = new IntVector(),
                    unused42          = 0,
                    consumable        = new Item(),
                    equipment         = new Item[13],
                    name              = "ET_bot",
                    skillDistribution = new SkillDistribution()
                    {
                        ability1 = 5,
                        ability2 = 5,
                        ability3 = 5,
                    },
                    manaCubes = 0,
                };
                for (int i = 0; i < 13; i++)
                {
                    playerstats.equipment[i] = new Item();
                }
                playerstats.Write(writer);
                stopWatch.Start();
                players.Add(personalGuid, playerstats);
                break;

                #endregion
            case 17:     //serving sending the right version if yours is wrong
                #region version
                var version = new ProtocolVersion(reader);
                break;

                #endregion
            case 18:
                #region server full
                //empty
                break;

                #endregion
            default:
                Console.WriteLine(string.Format("unknown packet id: {0}", packetid));
                break;
            }
        }
Example #21
0
        public EntityUpdate(BinaryReader reader)
        {
            byte[] uncompressed = Zlib.Decompress(reader.ReadBytes(reader.ReadInt32()));

            MemoryStream stream = new MemoryStream(uncompressed);
            BinaryReader r      = new BinaryReader(stream);

            guid = r.ReadInt64();
            var bitfield = r.ReadInt64();

            if (Tools.GetBit(bitfield, 0))
            {
                position = new LongVector(r);
            }
            if (Tools.GetBit(bitfield, 1))
            {
                rotation = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 2))
            {
                velocity = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 3))
            {
                acceleration = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 4))
            {
                extraVel = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 5))
            {
                viewportPitch = r.ReadSingle();
            }
            if (Tools.GetBit(bitfield, 6))
            {
                physicsFlags = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 7))
            {
                hostility = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 8))
            {
                entityType = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 9))
            {
                mode = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 10))
            {
                modeTimer = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 11))
            {
                combo = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 12))
            {
                lastHitTime = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 13))
            {
                appearance = new Appearance(r);
            }
            if (Tools.GetBit(bitfield, 14))
            {
                entityFlags = r.ReadInt16();
            }
            if (Tools.GetBit(bitfield, 15))
            {
                roll = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 16))
            {
                stun = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 17))
            {
                slow = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 18))
            {
                ice = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 19))
            {
                wind = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 20))
            {
                showPatchTime = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 21))
            {
                entityClass = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 22))
            {
                specialization = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 23))
            {
                charge = r.ReadSingle();
            }
            if (Tools.GetBit(bitfield, 24))
            {
                unused24 = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 25))
            {
                unused25 = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 26))
            {
                rayHit = new FloatVector(r);
            }
            if (Tools.GetBit(bitfield, 27))
            {
                HP = r.ReadSingle();
            }
            if (Tools.GetBit(bitfield, 28))
            {
                MP = r.ReadSingle();
            }
            if (Tools.GetBit(bitfield, 29))
            {
                block = r.ReadSingle();
            }
            if (Tools.GetBit(bitfield, 30))
            {
                multipliers = new Multipliers(r);
            }
            if (Tools.GetBit(bitfield, 31))
            {
                unused31 = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 32))
            {
                unused32 = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 33))
            {
                level = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 34))
            {
                XP = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 35))
            {
                parentOwner = r.ReadInt64();
            }
            if (Tools.GetBit(bitfield, 36))
            {
                unused36 = r.ReadInt64();
            }
            if (Tools.GetBit(bitfield, 37))
            {
                powerBase = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 38))
            {
                unused38 = r.ReadInt32();
            }
            if (Tools.GetBit(bitfield, 39))
            {
                unused39 = new IntVector(r);
            }
            if (Tools.GetBit(bitfield, 40))
            {
                spawnPos = new LongVector(r);
            }
            if (Tools.GetBit(bitfield, 41))
            {
                unused41 = new IntVector(r);
            }
            if (Tools.GetBit(bitfield, 42))
            {
                unused42 = r.ReadByte();
            }
            if (Tools.GetBit(bitfield, 43))
            {
                consumable = new Item(r);
            }
            if (Tools.GetBit(bitfield, 44))
            {
                equipment = new Item[13];
                for (int i = 0; i < 13; i++)
                {
                    equipment[i] = new Item(r);
                }
            }
            if (Tools.GetBit(bitfield, 45))
            {
                name = new string(r.ReadChars(16));
                name = name.Substring(0, name.IndexOf("\0"));
            }
            if (Tools.GetBit(bitfield, 46))
            {
                skillDistribution = new SkillDistribution(r);
            }
            if (Tools.GetBit(bitfield, 47))
            {
                manaCubes = r.ReadInt32();
            }
        }
Example #22
0
 public void Filter(EntityUpdate previous)
 {
     if (position != null)
     {
         if (Math.Abs(position.x - previous.position.x) < 100000 &&
             Math.Abs(position.y - previous.position.y) < 100000 &&
             Math.Abs(position.z - previous.position.z) < 100000)
         {
             position = null;
         }
     }
     rotation = null;
     if (velocity != null)
     {
         if (Math.Abs(velocity.z - previous.velocity.z) < 2)
         {
             velocity = null;
         }
     }
     if (acceleration != null)
     {
         if (Math.Abs(acceleration.x - previous.acceleration.x) < 10 &&
             Math.Abs(acceleration.y - previous.acceleration.y) < 10 &&
             Math.Abs(acceleration.z - previous.acceleration.z) < 10)
         {
             acceleration = null;
         }
     }
     if (extraVel != null)
     {
         if (Math.Abs(extraVel.x) < 1 &&
             Math.Abs(extraVel.y) < 1 &&
             Math.Abs(extraVel.z) < 1)
         {
             extraVel = null;
         }
     }
     viewportPitch = null;
     physicsFlags  = null;
     if (modeTimer != null && modeTimer > 100)
     {
         previous.modeTimer = modeTimer;//necessary for rayhit filtering
         modeTimer          = null;
     }
     lastHitTime = null;
     if (roll != null && !(roll > 500))
     {
         roll = null;
     }
     if (stun != null && stun < previous.stun)
     {
         stun = null;
     }
     if (slow != null && slow < previous.slow)
     {
         slow = null;
     }
     if (ice != null && ice < previous.ice)
     {
         ice = null;
     }
     if (wind != null && wind < previous.wind)
     {
         wind = null;
     }
     showPatchTime = null;
     if (charge != null)
     {
         if (Math.Abs((float)(charge - previous.charge)) < 0.1f)
         {
             charge = null;
         }
     }
     unused24 = null;
     unused25 = null;
     if (rayHit != null)
     {
         if (previous.mode == 0 || previous.modeTimer > 1500 || //current could be null
             (Math.Abs(rayHit.x - previous.rayHit.x) < 1.5f &&
              Math.Abs(rayHit.y - previous.rayHit.y) < 1.5f &&
              Math.Abs(rayHit.z - previous.rayHit.z) < 1.5f))
         {
             rayHit = null;
         }
     }
     MP                = null;
     multipliers       = null;
     unused31          = null;
     unused32          = null;
     XP                = null;
     unused36          = null;
     powerBase         = null;
     unused38          = null;
     unused39          = null;
     spawnPos          = null;
     unused41          = null;
     unused42          = null;
     skillDistribution = null;
     manaCubes         = null;
 }
Example #23
0
 private void Start()
 {
     multi      = GameObject.Find("Main Camera").GetComponent <Multipliers>();
     startSpeed = speed;
     player     = GameObject.Find("Main Camera").GetComponent <Player>();
 }
Example #24
0
 public void UpdateScore()
 {
     if (check == 1)
     {
         if (check1 == 1)
         {
             if (GameValue <= 0 || Timer <= 0 || SpawnCollectible.CountCollectible <= 0)
             {
                 LedEffect.t = 2f;
                 Multipliers.SetActive(false);
                 Timers.SetActive(false);
                 if (GameValue < 0)
                 {
                     GameValue = 0;
                 }
                 check      = 0;
                 Pause.j    = 1;
                 GameOver.j = 1;
             }
         }
         else if (check1 == 0)
         {
             if (GameValue <= 0 || GameValue >= setScore || SpawnCollectible.CountCollectible <= 0)
             {
                 LedEffect.t = 2f;
                 Multipliers.SetActive(false);
                 Timers.SetActive(false);
                 if (GameValue < 0)
                 {
                     GameValue = 0;
                 }
                 check      = 0;
                 Pause.j    = 1;
                 GameOver.j = 1;
             }
         }
     }
     if (check != 1)
     {
         if (GameValue <= 0 || SpawnCollectible.CountCollectible <= 0)
         {
             LedEffect.t = 2f;
             Multipliers.SetActive(false);
             if (GameValue < 0)
             {
                 GameValue = 0;
             }
             Pause.j    = 1;
             GameOver.j = 1;
         }
     }
     if (GameValue < 100)
     {
         if (GameValue < 10)
         {
             health.text = "00" + GameValue.ToString();
         }
         else
         {
             health.text = "0" + GameValue.ToString();
         }
     }
     else
     {
         health.text = GameValue.ToString();
     }
 }