Exemplo n.º 1
0
        /// <summary>
        ///   Kosntruktor
        /// </summary>
        /// <param name="locationBehavior"> Position des Spielers auf der Map </param>
        /// <param name="maxHealth"> Maximal Leben </param>
        /// <param name="health"> Aktuelles Leben </param>
        /// <param name="speed"> Bewegungsgeschwindigkeit </param>
        public Player(ILocationBehavior locationBehavior, float maxHealth, float health, float speed)
            : base(locationBehavior)
        {
            Buffs = new Dictionary<EBuffType, Buff>();
            Speed = speed;
            MaxHealth = maxHealth;
            Health = maxHealth;

            // Texturen für Renderer laden
            RendererStanding = LoadedRenderer.GetStatic("S_Player_Standing");
            RendererBigWeapon = LoadedRenderer.GetStatic("S_Player_BW");
            RendererBigWeaponShot = LoadedRenderer.GetStatic("S_Player_BW_Shot");
            RendererSmallWeapon = LoadedRenderer.GetStatic("S_Player_SW");
            RendererSmallWeaponShot = LoadedRenderer.GetStatic("S_Player_SW_Shot");

            RendererDying = LoadedRenderer.GetAnimation("A_Splatter_01");
            RendererDying.PlayOnce();

            Texture2D[] textureFootMoving = new[]
                                                {
                                                    Main.ContentManager.Load<Texture2D>("images/character/left_foot"),
                                                    Main.ContentManager.Load<Texture2D>("images/character/right_foot")
                                                };
            RendererFootMoving = new AnimationRenderer(textureFootMoving, 4F);

            _footRenderer = new NoRenderer();

            // Location für die Füße
            _footLocation = new MapLocation(locationBehavior.Position,
                                           new Vector2(textureFootMoving[0].Width, textureFootMoving[0].Height));

            // Standardmäßig den StandingRenderer zuweisen
            //Renderer = RendererBigWeapon;

            // LocationSize anpassen
            LocationSizing();
            LocationBehavior.Size = Renderer.Size; // Sollte LocationSizing machen

            // InventarListe init
            Inventar = new Dictionary<int, int>();

            Shortcuts = new Dictionary<int, Weapon>();
            // Schusstime auf 0 setzten
            _shotTimer = 0;

            // Poweruplist init
            ActivePowerups = new List<Powerup>();

            // Liquids auf 0 setzten
            Liquids = new Vector3(0, 0, 0);

            // Rect Methode setzten
            base.GetRect = base.RectPlayer;
        }
Exemplo n.º 2
0
        /*
        // ***************************************************************************
        // Clonet ein DefaultRenderer
        public static AnimationRenderer Get(ERenderer e)
        {
            AnimationRenderer a = (AnimationRenderer)DefaultRenderer[e].Clone();
            return a;
        }*/
        // ***************************************************************************
        // Load Animation
        public static void Load(string name, String file, int frames, float framesPerSecond)
        {
            // Array mit texturen erstellen
            Texture2D[] array = new Texture2D[frames];

            // Einzelne Bilder einladen
            for (int i = 0; i < frames; i++)
            {
                String f = "";
                if (i < 100 && frames >= 100)
                    f += "0";
                if (i < 10 && frames >= 10)
                    f += "0";
                f += i;

                array[i] = Main.ContentManager.Load<Texture2D>("animation/" + file + "/" + file + "_" + f);
            }

            AnimationRenderer a = new AnimationRenderer(array, framesPerSecond);
            a.Name = name;

            // Renderer erstellen
            LoadedRenderer.DefaultRenderer.Add(a.Name, a);
        }