示例#1
0
    public void Test4()
    {
        var s = "&z _upon 407298a --- ???ry, ww/100 I thought, 631str*ng and w===y -721&()"; // "407 407 Lucky"
        var r = "407 407 Lucky";

        Assert.AreEqual(r, Cubes.isSumOfCubes(s));
    }
示例#2
0
 public void AddCubesValues(Cubes neighbourCube)
 {
     cubeValue += neighbourCube.GetCubeValue();
     CubeChangeColor();
     UpdateLabel();
     Destroy(neighbourCube.gameObject);
 }
示例#3
0
 private void OnDeleteCube()
 {
     _cubeService.DeleteCube(SelectedCube);
     Cubes.Remove(SelectedCube);
     SelectedCube = null;
     ((DelegateCommand)DeleteCubeCommand).RaiseCanExecuteChanged();
 }
    public virtual void Command(Direction.Cube direction, int[][] _cubesOccup)
    {
        if (!this.hasInteraction)
        {
            return;
        }

        this.hasInteraction = false;

        Dictionary <string, int> newPosInfo = Cubes.GetCubeNewPos(this.curPos, _cubesOccup, direction);

        int[] oldMatrixPos = new int[] {
            newPosInfo["y"],
            newPosInfo["x"]
        };

        int[] newMatrixPos = new int[] {
            newPosInfo["newY"],
            newPosInfo["newX"]
        };

        manager.SwitchMatrixValue(oldMatrixPos, 0);
        manager.SwitchMatrixValue(newMatrixPos, newPosInfo["cubeID"]);

        CubeAction(newMatrixPos);
    }
示例#5
0
    protected override void SpawnCubes()
    {
        var size     = CubePrefab.GetComponent <BoxCollider>().size;
        var cubeSize = size * CubeSize;

        //we want the cube of cubes to be centered on this game object
        var centerOffset = cubeSize * (SideLength / 2f) * GapFactor;

        centerOffset = new Vector3(centerOffset.x, centerOffset.y, 0f);
        var cubeOffset = (cubeSize * GapFactor / 2f);

        cubeOffset = new Vector3(cubeOffset.x, cubeOffset.y, 0f);
        var finalOffset = /*transform.position */ -centerOffset + cubeOffset;

        for (var j = 0; j < SideLength; j++)
        {
            for (var i = 0; i < SideLength; i++)
            {
                var pos  = (new Vector3(cubeSize.x * i, cubeSize.y * j, 0) * GapFactor) + finalOffset;
                var cube = (GameObject)Instantiate(CubePrefab, pos, Quaternion.identity);
                cube.transform.localScale = new Vector3(CubeSize, CubeSize, CubeSize);
                cube.transform.SetParent(transform, false);

                PreCubeSpawned(cube, i, j);

                Cubes.Add(cube);
                NetworkServer.Spawn(cube);

                RpcSetAsChild(cube);

                PostCubeSpawned(cube);
            }
        }
    }
示例#6
0
    public void Test1()
    {
        var s = "0 9026315 -827&()"; // "0 0 Lucky"
        var r = "0 0 Lucky";

        Assert.AreEqual(r, Cubes.isSumOfCubes(s));
    }
示例#7
0
        public void CalculateNextState()
        {
            int activeNeighbourCount = Cubes
                                       .CountActive(Neighbours.Adjustments, this.Position.X, this.Position.Y, this.Position.Z);

            this.NextState = this.State == true ? activeNeighbourCount >= 2 && activeNeighbourCount <= 3 : activeNeighbourCount == 3;
        }
    public static AnimationClip setAnimationTo(GameObject objectToAnim, int[] nextPos, Direction.Cube upOrDown)
    {
        // Debug.Log("animation: " + objectToAnim.name);
        // Debug.Log("animation: " + nextPos[1]);
        // Debug.Log("animation: " + upOrDown);
        var myNextPos = Cubes.GetWorldPosition(nextPos);
        // AnimationCurve curveX, curveY, curveZ;

        AnimationClip clip = new AnimationClip();

        clip.legacy = true;

        var oldPos = objectToAnim.transform.position;

        if (upOrDown == Direction.Cube.Up)
        {
            clip = setCustomKeyFramesToClip(clip, oldPos.x, oldPos.x, myNextPos.x, "localPosition.x");
            clip = setCustomKeyFramesToClip(clip, oldPos.z, oldPos.z, myNextPos.z, "localPosition.z");
            clip = setCustomKeyFramesToClip(clip, oldPos.y, myNextPos.y, myNextPos.y, "localPosition.y");
        }
        else
        {
            clip = setCustomKeyFramesToClip(clip, oldPos.x, myNextPos.x, myNextPos.x, "localPosition.x");
            clip = setCustomKeyFramesToClip(clip, oldPos.z, myNextPos.z, myNextPos.z, "localPosition.z");
            clip = setCustomKeyFramesToClip(clip, oldPos.y, oldPos.y, myNextPos.y, "localPosition.y");
        }

        AnimationEvent animEv = new AnimationEvent();

        animEv.time         = 2.0f;
        animEv.functionName = "OnAnimationEnded";
        clip.events         = new AnimationEvent[] { animEv };

        return(clip);
    }
示例#9
0
 private void RpcSetShrinkCubeSize(float newSize)
 {
     foreach (var cube in Cubes.Where(c => c != null))
     {
         cube.GetComponent <ShrinkOnProximity>().SetInitialScale(newSize);
     }
 }
示例#10
0
    public void Test2()
    {
        var s = "aqdf& 0 1 xyz 153 777.777";
        var r = "0 1 153 154 Lucky";

        Assert.AreEqual(r, Cubes.isSumOfCubes(s));
    }
示例#11
0
    public void Test3()
    {
        var s = "QK29 45[&erui";
        var r = "Unlucky";

        Assert.AreEqual(r, Cubes.isSumOfCubes(s));
    }
        public void Test1()
        {
            string s = "0 9026315 -827&()"; // "0 0 Lucky"
            String r = "0 0 Lucky";

            Assert.AreEqual(r, Cubes.isSumOfCubes(s));
        }
示例#13
0
 bool CheckCube(Cubes cube)
 {
     if (nullCount > 0 && cube == null)
     {
         return(true);
     }
     if (cube == null)
     {
         nullCount++;
         return(false);
     }
     if (fakeCount > 0 && !cube.IsReal)
     {
         return(true);
     }
     if (starterCubes.Count != 0)
     {
         foreach (var item in starterCubes)
         {
             if (item == null)
             {
                 continue;
             }
             if (item.Name.Equals(cube.Name))
             {
                 return(true);
             }
         }
     }
     if (!cube.IsReal)
     {
         fakeCount++;
     }
     return(false);
 }
示例#14
0
            public int RunChallenge(List <string> input)
            {
                // Also consider qubes next to initial state
                input.Insert(0, new String('.', input[0].Length));
                input.Add(new String('.', input[0].Length));
                input = input.Select(s => s = '.' + s + '.').ToList();

                for (int y = 0; y < input.Count; y++)
                {
                    for (int x = 0; x < input[0].Length; x++)
                    {
                        var active = input[y][x] == '#';

                        for (int z = -1; z <= 1; z++)
                        {
                            for (int w = -1; w <= 1; w++)
                            {
                                var value = (z == 0 && w == 0) ? active : false;
                                Cubes.Add(new Coordinate4D {
                                    X = x, Y = y, Z = z, W = w
                                }, value);
                            }
                        }
                    }
                }

                for (int cycle = 0; cycle < 6; cycle++)
                {
                    NextCubes = new Dictionary <Coordinate4D, bool>();
                    foreach (var cube in Cubes)
                    {
                        var neighbors = GetNeighbors(cube.Key).Count(n => n);
                        if (cube.Value)
                        {
                            if (neighbors == 2 || neighbors == 3)
                            {
                                NextCubes.Add(cube.Key, true);
                            }
                            else
                            {
                                NextCubes.Add(cube.Key, false);
                            }
                        }
                        else
                        {
                            if (neighbors == 3)
                            {
                                NextCubes.Add(cube.Key, true);
                            }
                            else
                            {
                                NextCubes.Add(cube.Key, false);
                            }
                        }
                    }
                    Cubes = NextCubes;
                }
                return(Cubes.Values.Count(z => z));
            }
示例#15
0
        public void Update()
        {
            if (GetComponent <KeyboardHandler>().KeyPressed(Keys.Right))
            {
                MainCube.TurnRight();
            }
            else if (GetComponent <KeyboardHandler>().KeyPressed(Keys.Left))
            {
                MainCube.TurnLeft();
            }
            else if (GetComponent <KeyboardHandler>().KeyPressed(Keys.Up))
            {
                MainCube.FlipUp();
            }
            else if (GetComponent <KeyboardHandler>().KeyPressed(Keys.Down))
            {
                MainCube.FlipDown();
            }

            if (GetComponent <KeyboardHandler>().KeyPressed(Keys.W))
            {
                MoveFormation(new Vector3(0, 0, -1));
            }
            if (GetComponent <KeyboardHandler>().KeyPressed(Keys.A))
            {
                MoveFormation(new Vector3(-1, 0, 0));
            }
            if (GetComponent <KeyboardHandler>().KeyPressed(Keys.S))
            {
                MoveFormation(new Vector3(0, 0, 1));
            }
            if (GetComponent <KeyboardHandler>().KeyPressed(Keys.D))
            {
                MoveFormation(new Vector3(1, 0, 0));
            }

            MainCube.Update();

            for (int i = 0; i < Cubes.Count; i++)
            {
                var cube = Cubes[i];
                cube.Update();
                if (cube.CanBeRemoved)
                {
                    Cubes.Remove(cube);
                    i--;
                }
            }
            for (int i = 0; i < Projections.Count; i++)
            {
                var proj = Projections[i];
                proj.Update();
                if (proj.CanBeRemoved)
                {
                    Projections.Remove(proj);
                    i--;
                }
            }
        }
示例#16
0
 public ICube[] Except(ICoverage excptCov)
 {
     if (Bitness != excptCov.Bitness)
     {
         throw new ArgumentException();
     }
     return(Cubes.Except(excptCov.ToCubesArray()).ToArray());
 }
示例#17
0
    public void Test5()
    {
        var s =
            "&z371 upon 407298a --- dreary, ###100.153 I thought, 9926315strong and weary -127&() 1"; // "371 407 153 1 932 Lucky"
        var r = "371 407 153 1 932 Lucky";

        Assert.AreEqual(r, Cubes.isSumOfCubes(s));
    }
示例#18
0
        private void cubesDeleteButton_Click(object sender, EventArgs e)
        {
            var cube = (Cube)cubesListView.SelectedObject;

            OlapWarehouse.Cubes.Remove(cube);
            Cubes.Remove(cube);
            cubesListView.SelectObject(null);
        }
示例#19
0
        public CityState(City city)
        {
            Name     = city.Name;
            Location = city.Location;
            Colour   = city.Colour;

            _cubes = new Cubes();
        }
示例#20
0
 public ICube[] Intersection(ICoverage intrsctCov)
 {
     if (Bitness != intrsctCov.Bitness)
     {
         throw new ArgumentException();
     }
     return(Cubes.Intersect(intrsctCov.ToCubesArray()).ToArray());
 }
示例#21
0
 public override string ToString()
 {
     if (Cubes == null)
     {
         return(new EmptyCoverage().ToString());
     }
     return(string.Join("\n", Cubes.Select(s => s.ToString())));
 }
示例#22
0
    private void RpcOnCubeSpawned(GameObject cube)
    {
        if (cube == null)
        {
            return;
        }

        Cubes.Add(cube);
    }
示例#23
0
        public ICube[] GetCubesByPow(byte pow)
        {
            if (Size == 0)
            {
                return((new EmptyCoverage()).ToCubesArray());
            }

            return(Cubes.Where(s => s.Power == pow).ToArray());
        }
示例#24
0
        private void cubesAddButton_Click(object sender, EventArgs e)
        {
            var cube = new Cube("New item");

            Cubes.Add(cube);
            SelectedServer.Cubes.Add(cube);
            cubesListView.SelectObject(cube);
            cubesListView.StartCellEdit(cubesListView.SelectedItem, 0);
        }
示例#25
0
        /// <summary>
        /// Executes the given LayerMove
        /// </summary>
        /// <param name="move">Defines the LayerMove to be executed</param>
        private void RotateLayer(LayerMove move)
        {
            int repetitions = move.Twice ? 2 : 1;

            for (int i = 0; i < repetitions; i++)
            {
                IEnumerable <Cube> affected = Cubes.Where(c => c.Position.HasFlag(move.Layer));
                affected.ToList().ForEach(c => c.NextPos(move.Layer, move.Direction));
            }
        }
示例#26
0
 public void Init(Tetromino definition)
 {
     tetrominoDefinition = definition;
     for (int i = 0; i < transform.childCount; i++)
     {
         Cubes.Add(transform.GetChild(i).gameObject);
     }
     tetrominoDefinition.Reset();
     UpdateBottomPart();
 }
示例#27
0
        public int Active(int dimensions, string input)
        {
            var cubes = new Cubes(input);

            for (var c = 0; c < 6; c++)
            {
                cubes = cubes.Process(dimensions);
            }

            return(cubes.Count);
        }
示例#28
0
 public PandemicGameState(PandemicBoard board)
 {
     _board        = board;
     InfectionRate = 2;
     // todo: shuffle
     InfectionDeck        = new Stack <string>(_board.Cities.Select(c => c.Name));
     InfectionDiscardPile = new Stack <string>();
     CityStates           = _board.Cities.Select(c => new CityState(c)).ToList();
     _cityNameLookup      = BuildCityNameLookup(CityStates);
     CubePile             = CreateNewCubePile();
 }
示例#29
0
 private void RpcClearNullCubes()
 {
     for (var i = 0; i < Cubes.Count; i++)
     {
         if (Cubes[i] != null)
         {
             continue;
         }
         Cubes.RemoveAt(i);
         i--;
     }
 }
示例#30
0
        public void AddCube(Point position, bool isFormationLeader)
        {
            var cube = new Cube(this, position, isFormationLeader);

            cube.LoadContent();
            Cubes.Add(cube);

            var projection = new CubeProjection(this, cube);

            projection.LoadContent();
            Projections.Add(projection);
        }
示例#31
0
 public BackgammonManager(GameMode gameMode, string firstPlayerName, string secondPlayerName)
 {
     this.mode = gameMode;
     InitPlayers(gameMode, firstPlayerName, secondPlayerName);
     cubes = new Cubes();
 }