Пример #1
0
    //Routine to randomize the powerup collectible's position and type
    void Randomize()
    {
        bool valid=false;   //Flag to determine if randomized powerup is valid for mode

        const float Pwr_Min=(float)((int)Toolbox.Pwrs.Nothing); //The minimum powerup to randomize.range
        const float Pwr_Max = (float)((int)Toolbox.Pwrs.Random); //The maximum powerup to randomize.range
        UnityEngine.Random.seed = (int)System.DateTime.Now.Ticks;   //@Get new randomization seed from system time. Needs to be synce in netgames!

        //Loop until a valid powerup is gotten
        while (valid==false)
        {
            Pwr_Type = (Toolbox.Pwrs)((int)(UnityEngine.Random.Range(Pwr_Min,Pwr_Max)));
            if (Toolbox.Options.Mode==Toolbox.mode.Pinball)
            {
                valid=ValidPin[(byte)Pwr_Type];
            }
            else
            {
                valid=ValidAir[(byte)Pwr_Type];
            }
        }

        //Set textures
        Powerup.renderer.material.mainTexture = Tex[(byte)Pwr_Type];
        Toolbox.Position.RandomizeInRegion(Spawner, Powerup, radius_X, radius_Z);
        Alive = true;   //Make the powerup alive
    }
Пример #2
0
    //Routine to randomize the powerup collectible's position and type
    void Randomize()
    {
        bool valid=false;   //Flag to determine if randomized powerup is valid for mode
        Vector3 NewPos;     //New position vector

        const float Pwr_Min=(float)((int)Toolbox.Pwrs.Nothing); //The minimum powerup to randomize.range
        const float Pwr_Max = (float)((int)Toolbox.Pwrs.Random); //The maximum powerup to randomize.range
        UnityEngine.Random.seed = (int)System.DateTime.Now.Ticks;   //@Get new randomization seed from system time. Needs to be synce in netgames!

        //Get random X & Z offset, and Type of powerup
        x = UnityEngine.Random.Range(-radius_X, radius_X);
        z = UnityEngine.Random.Range(-radius_Z, radius_Z);

        //Loop until a valid powerup is gotten
        while (valid==false)
        {
            Pwr_Type = (Toolbox.Pwrs)((int)(UnityEngine.Random.Range(Pwr_Min,Pwr_Max)));
            if (Toolbox.Options.Mode==Toolbox.mode.Pinball)
            {
                valid=ValidPin[(byte)Pwr_Type];
            }
            else
            {
                valid=ValidAir[(byte)Pwr_Type];
            }
        }

        //Set textures
        Powerup.renderer.material.mainTexture = Tex[(byte)Pwr_Type];

        //Place It, relative to Spawner
        NewPos.x = Spawn_X + x;
        NewPos.y = Spawn_Y;
        NewPos.z = Spawn_Z+z;
        Powerup.gameObject.transform.position = NewPos; //Update the position
        SoundManager.Play("Teleport");  //Play Teleport sfx
        Alive = true;   //Make the powerup alive
    }