Ejemplo n.º 1
0
    // private Vector2 screenBounds;
    public static void CreateSpeedRing(float xPosition, List <SpeedRing> speedRingList)
    {
        bool canSpawnHere = false;

        // screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
        float     yPosition;
        Transform speedRingTransform = Instantiate(GameAssets.GetInstance().pfSpeedRing);

        while (!canSpawnHere)
        {
            // yPosition = Random.Range(-screenBounds.y, screenBounds.y);
            yPosition = Random.Range(MyGlobals.MAX_HEIGHT_GROUND, MyGlobals.SURFACE_POSITION);


            speedRingTransform.position = new Vector3(xPosition - 20f, yPosition);
            SpeedRing ring = new SpeedRing(speedRingTransform);

            canSpawnHere = PreventSpawnOverlap(ring.speedRingTransform);
            if (canSpawnHere)
            {
                speedRingList.Add(ring);
                break;
            }
        }
    }
        private static SpeedRing SpeedRingOnInit(On.Celeste.SpeedRing.orig_Init orig, SpeedRing self, Vector2 position,
                                                 float angle, Color color)
        {
            SpeedRing speedRing = orig(self, position, angle, color);

            speedRing.TrySetEntityId2(position, angle, color);
            speedRing.SetStartPosition(position);
            speedRing.SetAngle(angle);
            speedRing.SetColor(color);

            return(speedRing);
        }
Ejemplo n.º 3
0
        public void Update()
        {
            Playback.Update();
            Playback.Hair.AfterUpdate();
            if (Playback.Sprite.CurrentAnimationID == "dash" && Playback.Sprite.CurrentAnimationFrame == 0)
            {
                if (!dashing)
                {
                    dashing = true;
                    Celeste.Celeste.Freeze(0.05f);
                    SlashFx.Burst(Playback.Center, (-Vector2.UnitY).Angle()).Tag = tag;
                    dashTrailTimer   = 0.1f;
                    dashTrailCounter = 2;
                    CreateTrail();

                    launchedDelay = 0.15f;
                }
            }
            else
            {
                dashing = false;
            }
            if (dashTrailTimer > 0f)
            {
                dashTrailTimer -= Engine.DeltaTime;
                if (dashTrailTimer <= 0f)
                {
                    CreateTrail();
                    dashTrailCounter--;
                    if (dashTrailCounter > 0)
                    {
                        dashTrailTimer = 0.1f;
                    }
                }
            }
            if (launchedDelay > 0f)
            {
                launchedDelay -= Engine.DeltaTime;
                if (launchedDelay <= 0f)
                {
                    launched      = true;
                    launchedTimer = 0f;
                }
            }
            if (launched)
            {
                float prevVal = launchedTimer;
                launchedTimer += Engine.DeltaTime;
                if (launchedTimer >= 0.5f)
                {
                    launched      = false;
                    launchedTimer = 0f;
                }
                else if (Calc.OnInterval(launchedTimer, prevVal, 0.15f))
                {
                    SpeedRing speedRing = Engine.Pooler.Create <SpeedRing>().Init(Playback.Center, (Playback.Position - Playback.LastPosition).Angle(), Color.White);
                    speedRing.Tag = tag;
                    Engine.Scene.Add(speedRing);
                }
            }
        }
 public static void SetColor(this SpeedRing speedRing, Color direction)
 {
     speedRing.SetExtendedDataValue(SpeedRingColorKey, direction);
 }
 public static Color GetColor(this SpeedRing speedRing)
 {
     return(speedRing.GetExtendedDataValue <Color>(SpeedRingColorKey));
 }
 public static void SetAngle(this SpeedRing speedRing, float direction)
 {
     speedRing.SetExtendedDataValue(SpeedRingAngleKey, direction);
 }
 public static float GetAngle(this SpeedRing speedRing)
 {
     return(speedRing.GetExtendedDataValue <float>(SpeedRingAngleKey));
 }
 public static SpeedRing Clone(this SpeedRing speedRing)
 {
     return(Engine.Pooler.Create <SpeedRing>()
            .Init(speedRing.GetStartPosition(), speedRing.GetAngle(), speedRing.GetColor()));
 }