internal static void AddSingleSprite(MyTexture2D texture, MyVertexFormatSpritePositionTextureColor sprite)
        {
            if (m_currentInnerBatch.texture != texture.ShaderView)
            {
                if (m_currentInnerBatch.texture != null)
                    m_currentInnerBatch.Commit();

                m_currentInnerBatch = CreateSpritesBatch();
                m_currentInnerBatch.startInstance = m_spriteInstanceList.Count;
                m_currentInnerBatch.SetTexture(texture);
            }

            m_currentInnerBatch.AddSprite(sprite);
        }
        internal static void AddSingleSprite(MyTexture2D texture, Vector2 position, Rectangle? sourceRectangle, float scale, Color color)
        {
            Vector2 clipOffset;
            Vector2 clipScale;

            RectangleF destination;
            if (sourceRectangle != null)
            {
                destination = new RectangleF(position.X, position.Y, scale * sourceRectangle.Value.Width,
                    scale * sourceRectangle.Value.Height);
            }
            else
            {
                destination = new RectangleF(position.X, position.Y, scale, scale);
            }

            CalculateSpriteClipspace(destination,
                MyRender.ViewportResolution,
                out clipOffset, out clipScale);

            Vector2 texOffset = Vector2.Zero;
            Vector2 texScale = Vector2.One;

            if (sourceRectangle != null)
            {
                Vector2 textureSize = texture != null ? texture.Size : Vector2.Zero;

                Vector2 leftTop = new Vector2(sourceRectangle.Value.Left, sourceRectangle.Value.Top);
                Vector2 size = new Vector2(sourceRectangle.Value.Width, sourceRectangle.Value.Height);
                texOffset = leftTop / textureSize;
                texScale = size / textureSize;
            }

            AddSingleSprite(texture, new MyVertexFormatSpritePositionTextureColor(
                new HalfVector4(clipOffset.X, clipOffset.Y, clipScale.X, clipScale.Y),
                new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
                new Byte4(color.R, color.G, color.B, color.A)));
        }
 internal void SetTexture(MyTexture2D texture)
 {
     this.texture = texture.ShaderView;
 }
示例#4
0
    void Start()
    {
        Debug.Log("START: " + footstepInterval);

        _game = GameObject.Find(" GameController").GetComponent<GameController>();
        _wave = GameObject.Find(" GameController").GetComponent<WaveController>();
        _weapon = GetComponentInChildren<WeaponController>();
        _overviewCamera = GameObject.Find("Minimap Camera").GetComponent<CameraController>();

        Screen.showCursor = true;

        Texture2D left = Resources.Load("Textures/Weapon/TakeDamage0", typeof(Texture2D)) as Texture2D;
        Texture2D right = Resources.Load("Textures/Weapon/TakeDamage1", typeof(Texture2D)) as Texture2D;
        Color c = new Color(0.8f, 0, 0, 1f);
        leftDamage = new MyTexture2D(left,
            new Rect((Screen.width / 2) - left.width, (Screen.height - left.height) / 2, left.width, left.height), c);
        rightDamage = new MyTexture2D(right,
             new Rect(Screen.width / 2, (Screen.height - right.height) / 2, right.width, right.height), c);

        // Player Variables
        _life = MAX_LIFE;

        AudioSource[] a = GetComponents<AudioSource>();
        footstepsAudio = a[0];
        footstepsAudio.volume = 0.25f;
        jumpingAudio = a[1];
        voiceAudio = a[2];

        _motor = GetComponent<CharacterMotor>();
        //		footsteps = new AudioClip[1];
        //		footsteps[0] = Resources.Load("Sound/Player/jump") as AudioClip;
        footsteps = new AudioClip[3];
        footsteps[0] = Resources.Load("Sound/Player/foot_1") as AudioClip;
        footsteps[1] = Resources.Load("Sound/Player/foot_2") as AudioClip;
        footsteps[2] = Resources.Load("Sound/Player/foot_3") as AudioClip;
        onJumpAudio = Resources.Load("Sound/Player/Lilith_jump") as AudioClip;
        onLandAudio = Resources.Load("Sound/Player/Lilith_land") as AudioClip;
        onOutOfAmmo = Resources.Load("Sound/Player/Lilith_outofammo") as AudioClip;
    }