private Spiral PopulateSpiral(Spiral spiral)
 {
     LightCycle lightCycle = new LightCycle(spiral);
     for (int i = 0; i < spiral.Numbers.Length; i++)
     {
         lightCycle.DriveClockwise();
     }
     return spiral;
 }
Example #2
0
        private bool MoveCycle(LightCycle cycle, LightCycle other)
        {
            Point prev = cycle.Points.Last();
            Point next = Point.Origin;

            switch (cycle.Direction)
            {
            case Direction.North:
                next = new Point(prev.X, prev.Y - Size);
                break;

            case Direction.East:
                next = new Point(prev.X - Size, prev.Y);
                break;

            case Direction.South:
                next = new Point(prev.X, prev.Y + Size);
                break;

            case Direction.West:
                next = new Point(prev.X + Size, prev.Y);
                break;
            }

            if (next.X < 0 || next.Y < 0 || next.X > ScreenWidth || next.Y > ScreenHeight)
            {
                return(false);
            }


            foreach (Point p in cycle.Points)
            {
                if (next.X < p.X + Size && next.X + Size > p.X && next.Y < p.Y + Size && next.Y + Size > p.Y)
                {
                    return(false);
                }
            }

            foreach (Point p in other.Points)
            {
                if (next.X < p.X + Size && next.X + Size > p.X && next.Y < p.Y + Size && next.Y + Size > p.Y)
                {
                    return(false);
                }
            }

            cycle.Points.Add(next);

            return(true);
        }
Example #3
0
        /// <inheritdoc />
        public override void OnUpdate(float delta)
        {
            Delay(0.025f);

            Clear(Pixel.Presets.Black);

            foreach (Point p in playerA.Points)
            {
                FillRect(p, Size, Size, Pixel.Presets.Orange);
            }
            foreach (Point p in playerB.Points)
            {
                FillRect(p, Size, Size, Pixel.Presets.Cyan);
            }
            if (loser == null)
            {
                if (!MoveCycle(playerA, playerB))
                {
                    loser = playerA;
                }
                if (!MoveCycle(playerB, playerA))
                {
                    loser = playerB;
                }
            }
            else
            {
                if (loser == playerA)
                {
                    DrawTextHr(new Point(ScreenWidth * PixWidth / 3, ScreenHeight * PixHeight / 2), "Player A Loses", Pixel.Presets.White, 2);
                }

                else if (loser == playerB)
                {
                    DrawTextHr(new Point(ScreenWidth * PixWidth / 3, ScreenHeight * PixHeight / 2), "Player B Loses", Pixel.Presets.White, 2);
                }


                DrawTextHr(new Point(ScreenWidth * PixWidth / 3, ScreenHeight * PixHeight / 2 + 20), "Press 'Enter' To Restart", Pixel.Presets.White);

                if (GetKey(Key.Enter).Pressed)
                {
                    Reset();
                }
            }
        }
Example #4
0
        public static void cache_OnCommand(CommandEventArgs e)
        {
            NubiaPlayer p         = e.Mobile as NubiaPlayer;
            int         DD        = 10;
            int         NuitModus = 0;

            if (p.Competences.mustWait())
            {
                return;
            }
            if (LightCycle.ComputeLevelFor(p) > p.LightLevel)
            {
                if (LightCycle.ComputeLevelFor(p) > 10)
                {
                    NuitModus -= 5;
                }
                else if (LightCycle.ComputeLevelFor(p) < 10)
                {
                    NuitModus += 5;
                }

                p.SendMessage("Bonus de nuit: -" + NuitModus);
            }
            else
            {
                if (p.LightLevel > 10)
                {
                    NuitModus -= 5;
                }
                else if (p.LightLevel < 10)
                {
                    NuitModus += 5;
                }
                p.SendMessage("Bonus de nuit: -" + NuitModus);
            }
            DD += NuitModus;
            DD += (int)p.Taille * 2;
            bool mustBluff = false;
            int  DDBluff   = 10;

            foreach (NubiaMobile mob in p.GetMobilesInRange(8))
            {
                if (mob == p)
                {
                    continue;
                }
                if (mob.CanSee(p))
                {
                    int mobPsy = mob.Competences[CompType.Psychologie].intRoll() - NuitModus;
                    int bluff  = p.Competences[CompType.Bluff].intRoll() + NuitModus;
                    if (mobPsy < bluff)
                    {
                        mob.SendMessage("Quelques choses vous attire l'oeil plus loin");
                    }
                    DDBluff  += mobPsy - bluff;
                    mustBluff = true;
                }
            }

            if (mustBluff)
            {
                if (p.Competences[CompType.Bluff].roll(DDBluff))
                {
                    p.SendMessage("Vous réussissez à distraitre les observateurs pour vous cacher");
                }
                else
                {
                    p.SendMessage("Trop de monde vous observer, impossible de vous cacher");
                    return;
                }
            }

            if (p.Competences[CompType.Discretion].roll(DD))
            {
                p.SendMessage("Vous vous dissimulez avec discretion");
                p.Hidden = true;
            }
            else
            {
                p.SendMessage("Vous n'arrivez pas a vous dissimuler");
            }
            p.Competences.wait(1);
        }
Example #5
0
 public override void ComputeBaseLightLevels(Mobile m, out int global, out int personal)
 {
     global   = LightCycle.ComputeLevelFor(m);
     personal = m.LightLevel;
 }
Example #6
0
 private void Reset()
 {
     playerA = new LightCycle(10, 10, Direction.South);
     playerB = new LightCycle(ScreenWidth - 10, ScreenHeight - 10, Direction.North);
     loser   = null;
 }