Ejemplo n.º 1
0
    private void SetupRocks()
    => Enumerable.Range(0, Settings.RockCount)
    .ToList()
    .ForEach(_ => {
        var rock = Instantiate(
            Resources.Load("Rocks/" + Settings.MapType.ToString() + "/Large_" + UnityEngine.Random.Range(1, 5)),
            GetFixedPosition(GetValidPosition(), -1.0f),
            Quaternion.Euler(-90, UnityEngine.Random.Range(0, 360), 0)) as GameObject;

        rock.transform.parent     = RocksParentGameObject;
        rock.transform.localScale = new Vector3(UnityEngine.Random.Range(1, 4), UnityEngine.Random.Range(1, 4), UnityEngine.Random.Range(1, 4));
        Rocks.Add(rock.transform);
    });
Ejemplo n.º 2
0
        private void MoveRock(CellType currentType, Point current, Point destination, CellType[,] newState)
        {
            newState.Set(current, CellType.Empty);
            Rocks.Remove(current);
            IsChanged = true;
            if (currentType.IsHoRock() && !Cell.At(destination.Down()).IsEmpty())
            {
                newState.Set(destination, CellType.Lambda);
                Lambdas.Add(destination);
                HoRocks.Remove(current);
            }
            else
            {
                newState.Set(destination, currentType);
                Rocks.Add(destination);
            }

            if (Cell.At(destination.Down()).IsRobot())
            {
                State = MapState.Killed;
            }
        }
Ejemplo n.º 3
0
        private void MoveRobotTo(RobotCommand direction, Point destPos)
        {
            CellType destType = Cell.At(destPos);

            if (!destType.IsTraversible())
            {
                throw new InvalidMoveException(RobotPosition, destPos);
            }

            if (!destType.IsEmpty())
            {
                IsChanged = true;
            }

            if (destType.IsRock())
            {
                if (direction == RobotCommand.Left && Cell.At(destPos.Left()).IsEmpty())
                {
                    Cell.Set(destPos.Left(), destType);
                    Rocks.Remove(destPos);
                    Rocks.Add(destPos.Left());
                    if (destType.IsHoRock())
                    {
                        HoRocks.Remove(destPos);
                        HoRocks.Add(destPos.Left());
                    }
                }
                else if (direction == RobotCommand.Right && Cell.At(destPos.Right()).IsEmpty())
                {
                    Cell.Set(destPos.Right(), destType);
                    Rocks.Remove(destPos);
                    Rocks.Add(destPos.Right());
                    if (destType.IsHoRock())
                    {
                        HoRocks.Remove(destPos);
                        HoRocks.Add(destPos.Right());
                    }
                }
                else
                {
                    throw new InvalidMoveException(RobotPosition, destPos);
                }
            }

            if (destType.IsLambda())
            {
                Lambdas.Remove(destPos);
                Score += 25;
                LambdasCollected++;
            }

            if (destType.IsOpenLift())
            {
                State  = MapState.Won;
                Score += LambdasCollected * 50 - 1; // minus one point for the final move
            }

            if (destType.IsTrampoline())
            {
                Cell.Set(destPos, CellType.Empty);
                destPos = Trampolines[destPos];

                // remove all trampolines that have the same target
                var remove = new List <Point>();
                foreach (var trampoline in Trampolines)
                {
                    if (trampoline.Value == destPos)
                    {
                        Cell.Set(trampoline.Key, CellType.Empty);
                        remove.Add(trampoline.Key);
                    }
                }

                foreach (Point point in remove)
                {
                    Trampolines.Remove(point);
                }
            }

            if (destType.IsRazor())
            {
                RazorCount++;
                Razors.Remove(destPos);
            }

            Cell.Set(RobotPosition, CellType.Empty);
            Cell.Set(destPos, CellType.Robot);
            RobotPosition = destPos;
        }
Ejemplo n.º 4
0
 void RockSpawnerOutput.OnSpawn(Rock rock)
 {
     rocks.Add(rock);
 }
 public void AddRock(Rock rock)
 {
     Rocks.Add(rock);
 }