Example #1
0
        protected virtual void Load(Core.Transform transform)
        {
            // Physics
            AddComponent(new Body(this));
            AddComponent(new CircleCollider(this, CollisionChanell.Enemy, colliderOffset, colliderRadius));

            // HealthBar
            healthComponent           = AddComponent(new Gameplay.Health(this));
            healthComponent.MaxHealth = maxHealth;
            healthBar = AddComponent(new UI.HealthBar(this, healthBarOffset));
            healthComponent.OnDamageTaken += healthBar.Refresh;
            healthComponent.OnDamageTaken += OnDamage;
            healthComponent.OnDepleted    += Die;

            // AI
            aiAttack   = AddComponent(new Gameplay.AIAttack(this));
            movement   = AddComponent(new Navigation.MovementComponent(this));
            navigation = AddComponent(new Navigation.NavigationAgent(this));

            // Visual
            anim = AddComponent(new Graphics.StackAnimator(this));
        }
Example #2
0
        public InputComponent(Core.GameObject parent) : base(parent)
        {
            moveComp = parent.GetComponent <Navigation.MovementComponent>();
            gun      = Parent.GetComponent <Gameplay.Gun>();

            verticalAxis      = new AxisBinding(Keys.S, Keys.W);
            horizontalAxis    = new AxisBinding(Keys.D, Keys.A);
            shootBinding      = new ActionBinding(EMouseButton.Left);
            interactBinding   = new ActionBinding(Keys.E);
            scrollUpBinding   = new ActionBinding(EMouseButton.WheelUp);
            scrollDownBinding = new ActionBinding(EMouseButton.WheelDown);
            reloadBinding     = new ActionBinding(Keys.R);

            pistolSwapBinding   = new ActionBinding(Keys.D1);
            riffleSwapBinding   = new ActionBinding(Keys.D2);
            shotgunSwapBinding  = new ActionBinding(Keys.D3);
            launcherSwapBinding = new ActionBinding(Keys.D4);

            AttachBindings();

            InputManager.Manager.AddAxisBinding(verticalBindingName, verticalAxis);
            InputManager.Manager.AddAxisBinding(horizontalBindingName, horizontalAxis);

            InputManager.Manager.AddActionBinding(shootBindingName, shootBinding);
            InputManager.Manager.AddActionBinding(interactBindName, interactBinding);

            InputManager.Manager.AddActionBinding(scrollDownBindName, scrollDownBinding);
            InputManager.Manager.AddActionBinding(scrollUpBindName, scrollUpBinding);
            InputManager.Manager.AddActionBinding(reloadBindName, reloadBinding);

            InputManager.Manager.AddActionBinding(pistolSwapName, pistolSwapBinding);
            InputManager.Manager.AddActionBinding(riffleSwapName, riffleSwapBinding);
            InputManager.Manager.AddActionBinding(launcherSwapName, launcherSwapBinding);
            InputManager.Manager.AddActionBinding(shotgunSwapName, shotgunSwapBinding);

            moveComp.CurrentFocus             = target;
            InputManager.Manager.OnMouseMove += MoveTarget;
        }
Example #3
0
        private void Load(Transform _transform)
        {
            // Physics
            AddComponent(new Body(this));
            AddComponent(new CircleCollider(this, CollisionChanell.Player, Vector2.Zero, size / 3));
            //AddComponent(new CircleCollider(this, CollisionChanell.Hitbox, Vector2.Zero, size / 2));

            walkSFX		= AddComponent(new Audio.AudioSource(this, Audio.SoundContainer.Instance.GetSoundEffect("MonkeyWalk")));
            walkSFX.Pitch = 0.2f;
            hitSFX		= AddComponent(new Audio.AudioSource(this, Audio.SoundContainer.Instance.GetSoundEffect("MonkeyHit")));
            hitSFX.Pitch = 0.2f;
            idleSFX		= AddComponent(new Audio.AudioSource(this, Audio.SoundContainer.Instance.GetSoundEffect("MonkeyIdle")));
            idleSFX.Pitch = 0.2f;
            gameoverSFX	= AddComponent(new Audio.AudioSource(this, Audio.SoundContainer.Instance.GetSoundEffect("GameOver")));

            // Movement
            movement = AddComponent(new Navigation.MovementComponent(this));

            PlayerState? state = Core.GameManager.Instance.playerState;
            Console.WriteLine("loading player, state: " + state.HasValue);
            Gun gun = AddComponent(new Gun(this));
            if(state == null)
            {
                gun.AddAmmoClip(Gun.pistolClip.Copy());
                gun.AddAmmoClip(Gun.rifleClip.Copy());
                gun.AddAmmoClip(Gun.shotgunClip.Copy());
                gun.AddAmmoClip(Gun.launcherClip.Copy());
                gun.ChangeAmmo(typeof(PistolBullet));
            }
            else
            {
                foreach(ClipInfo clip in state.Value.ammo)
                    gun.AddAmmoClip(clip.Copy());

                gun.ChangeAmmo(state.Value.currentAmmoType);
            }

            inputComponent = AddComponent(new Input.InputComponent(this));

            // Health
            healthComponent = AddComponent(new Health(this));
            healthComponent.MaxHealth = 200;
            if(state.HasValue)
                healthComponent.CurrentValue = state.Value.health;
            healthComponent.OnDamageTaken += OnDamageTaken;
            healthComponent.OnDepleted += OnDeath;

            hud = Core.GameManager.SpawnObject(new UI.PlayerHUD(this));

            List<Rectangle> idle01 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) idle01.Add(new Rectangle(i * size, 0, size, size));
            AddComponent(new Graphics.Sprite(this, "monkey", idle01));

            AddComponent(new Graphics.StackAnimator(this));

            //STANIE
            List<Rectangle> idle02 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) idle02.Add(new Rectangle(i * size, size, size, size));
            GetComponent<Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("Idle",
                GetComponent<Graphics.Sprite>(),
                new List<List<Rectangle>> { idle01, idle02 },
                266,
                true));

            //CHODZENIE
            List<Rectangle> walk01 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) idle02.Add(new Rectangle(i * size, size * 2, size, size));
            List<Rectangle> walk02 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) walk02.Add(new Rectangle(i * size, size * 3, size, size));
            GetComponent<Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("Walk",
                GetComponent<Graphics.Sprite>(),
                new List<List<Rectangle>> { walk01, idle01, walk02, idle01},
                216,
                true));

            //TRZYMANIE
            List<Rectangle> hold01 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) hold01.Add(new Rectangle(i * size, size * 4, size, size));
            List<Rectangle> hold02 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) hold02.Add(new Rectangle(i * size, size * 5, size, size));
            GetComponent<Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("Hold",
                GetComponent<Graphics.Sprite>(),
                new List<List<Rectangle>> { hold01, hold02 },
                266,
                true));

            //TRZYMANIE I CHODZENIE
            List<Rectangle> holdwalk01 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) holdwalk01.Add(new Rectangle(i * size, size * 6, size, size));
            List<Rectangle> holdwalk02 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) holdwalk02.Add(new Rectangle(i * size, size * 7, size, size));
            GetComponent<Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("HoldWalk",
                GetComponent<Graphics.Sprite>(),
                new List<List<Rectangle>> { holdwalk01, hold01, holdwalk02, hold01},
                150,
                true));

            //UMIERANIE
            List<Rectangle> dead01 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) dead01.Add(new Rectangle(i * size, size * 8, size, size));
            List<Rectangle> dead02 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) dead02.Add(new Rectangle(i * size, size * 9, size, size));
            GetComponent<Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("Dead",
                GetComponent<Graphics.Sprite>(),
                new List<List<Rectangle>> { idle01, dead01, dead02 },
                298,
                false));

            //RZUCANIE
            List<Rectangle> throw01 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) throw01.Add(new Rectangle(i * size, size * 10, size, size));
            List<Rectangle> throw02 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) throw02.Add(new Rectangle(i * size, size * 11, size, size));
            List<Rectangle> throw03 = new List<Rectangle>();
            for(int i = 0; i < height; ++i) throw03.Add(new Rectangle(i * size, size * 12, size, size));
            GetComponent<Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("Throw",
                GetComponent<Graphics.Sprite>(),
                new List<List<Rectangle>> { throw01, throw01, throw02, throw03, hold01 },
                298,
                false));

            GetComponent<Graphics.StackAnimator>().SetAnimation("Hold");

            lightOff = Graphics.EffectContainer.Instance.GetEffect("LightOff");

            Audio.AudioManager.Instance.PlayerTransform = transform;

            HealthFx = Graphics.EffectContainer.Instance.GetEffect("HealthFX");

            Graphics.ViewManager.Instance.activeEffects.Add(HealthFx);

            Graphics.ViewManager.Instance.activeEffects.Add(Graphics.EffectContainer.Instance.GetEffect("BloodScreen"));
        }