Example #1
0
        public PlayerEntity()
        {
            Sprite[] sprites = FeContent.LoadSpriteSheet("character/charAtlas.feAsset");

            Animation           anim  = new Animation(sprites, "walk", .1f);
            AnimationController contr = new AnimationController(anim);

            Renderer          = new SpriteRenderer(sprites[0]);
            Renderer.Material = new Material(SandboxGame.TestEffect);

            AnimationComponent animComponent = new AnimationComponent(Renderer, contr);

            Bind(Renderer);
            Bind(animComponent);



            BoxCollider col = new BoxCollider(sprites[0].Width, sprites[0].Height, Vector2.Zero);

            Bind(col);

            col.OnCollisionEnter += o => FeLog.Debug($"PLAYER ENTER: {this}");
            col.OnCollisionExit  += o => FeLog.Debug($"PLAYER EXIT: {this}");


            ParticleType partType = new ParticleType(FeContent.LoadSprite("box.png"))
            {
                Lifetime       = ParticleLifetime.RandomRange(0.5f, 1f),
                StartAngle     = ParticleAngle.RandomRange(0, 360),
                StartSpeed     = ParticleSpeed.RandomRange(-2f, 2f),
                StartDirection = ParticleDirection.RandomRange(0, 360)
            };

            ParticleEmitter emitter = new ParticleEmitter(partType)
            {
                AutoEmit       = true,
                BurstCunt      = 5,
                EmitDelay      = 3,
                BurstSteps     = 8,
                BurstStepDelay = .1f
            };

            Bind(emitter);



            Bind(new PlayerComponent());
            //Bind(new PlayerComponentGamepad());
        }
Example #2
0
        public ParticleType(Sprite sprite)
        {
            Sprite     = sprite;
            StartColor = Color.White;

            Lifetime = ParticleLifetime.Fixed(1f);

            StartSpeed   = ParticleSpeed.Fixed(0f);
            Acceleration = ParticleAcceleration.Fixed(0f);

            StartSize = ParticleSize.Fixed(1f);
            Growth    = ParticleGrowth.Fixed(0f);

            StartAngle = ParticleAngle.Fixed(0f);
            Rotation   = ParticleRotation.Fixed(0f);

            StartDirection = ParticleDirection.Fixed(0f);
        }
    void Start()
    {
        GameObject gameControllerObject = GameObject.FindWithTag("GameController");

        if (gameControllerObject != null)
        {
            gameController = gameControllerObject.GetComponent <GameController>();
        }

        if (gameController == null)
        {
            Debug.Log("Cannot find 'GameController' script");
        }

        GameObject bgScrollerObject = GameObject.FindWithTag("BGScroller");

        if (bgScrollerObject != null)
        {
            bgScroller = bgScrollerObject.GetComponent <BGScroller>();
        }

        if (bgScroller == null)
        {
            Debug.Log("Cannot find 'BGScroller' script");
        }

        GameObject particleObject = GameObject.FindWithTag("particles");

        if (particleObject != null)
        {
            ps = particleObject.GetComponent <ParticleSpeed>();
        }

        if (ps == null)
        {
            Debug.Log("Cannot find 'Particle Speed' script");
        }
    }