Example #1
0
		public override void Reset () {
			gameObject = new ConcreteGameObjectVar(this.self);
			center = Vector3.zero;
			size = new Vector3(1f, 1f, 1f);
			color = Color.white * .5f;
			cubeType = CubeType.Wired;
		}
Example #2
0
 public CubeType pickCounterCube(CubeType pickToCounter)
 {
     switch(pickToCounter) {
         case CubeType.red:
             if(Random.Range(0, 1) == 0)
                 return CubeType.black;
             else
                 return CubeType.green;
         case CubeType.blue:
             if(Random.Range(0, 1) == 0)
                 return CubeType.red;
             else
                 return CubeType.white;
         case CubeType.green:
             if(Random.Range(0, 1) == 0)
                 return CubeType.blue;
             else
                 return CubeType.black;
         case CubeType.black:
             if(Random.Range(0, 1) == 0)
                 return CubeType.blue;
             else
                 return CubeType.white;
         case CubeType.white:
             if(Random.Range(0, 1) == 0)
                 return CubeType.green;
             else
                 return CubeType.red;
         default:
             Debug.Log("default called, something went wrong");
             Debug.Break();
             return CubeType.none;
     }
 }
Example #3
0
 public Cube(string id, CubeType type, int point, float addTime, float expire)
 {
     Id = id;
     Type = type;
     Point = point;
     AddTime = addTime;
     Expire = expire;
 }
Example #4
0
        public GameObject InstantiateCube(CubeType cubeType, Vector3 position)
        {
            GameObject cube = InstantiateCube(cubeType);

            if (cube != null)
            {
                cube.transform.position = position;
            }

            return cube;
        }
Example #5
0
    // Gets the next action most likely from the given one.
    // We assume actions has nValue - 1 elements in it (i.e.
    // the size of the window).
    public CubeType getMostLikely(CubeType[] actions)
    {
        double startTime = Time.realtimeSinceStartup;

        if(actions.Length != nValue-1){
            Debug.Log("actions.Length != nValue");
            Debug.Break();
        }

        keyStringOfArray = "";
        keyStringOfArray = returnStringName(actions);

        //if we don't have data for the actions, we cant predict
        if (data[keyStringOfArray] == null){
            if(doDebugLogs)
                Debug.Log(playerThisNgramPredictorBelongsTo + ": Prediction fail: no data for this sequence: " + keyStringOfArray);
            return CubeType.none;
        }
        if(doDebugLogs)
            Debug.Log(playerThisNgramPredictorBelongsTo + " predicting sequence: " + keyStringOfArray);

        // Get the key data
        KeyDataRecord keyData = (KeyDataRecord)data[keyStringOfArray];

        // Find the highest probability
        int highestValue = 0;
        CubeType bestAction = CubeType.none;

        // Get the list of actions in the store
        ICollection possibleActions = keyData.counts.Keys;

        // Go through each
        foreach(CubeType action in possibleActions){
            // Check for the highest value
            if ((int)keyData.counts[action] > highestValue)
            {
                // Store the action
                highestValue = (int)keyData.counts[action];
                bestAction = action;
            }
        }

        double temp = Time.realtimeSinceStartup-startTime;
        overallTimeTakenForPredicting += temp;
        overallPredicts++;
        averageTimeTakenForPredicting = overallTimeTakenForPredicting / overallPredicts;

        return bestAction;
    }
Example #6
0
        public GameObject InstantiateCubeGroup(int groupId, CubeType cubeType, Vector3 coreCubePosition)
        {
            GameObject group = groups[groupId];
            GameObject coreCube = InstantiatePivotCube(cubeType, coreCubePosition);

            for (int i = 0; i < group.transform.childCount; i++)
            {
                var childTransform = group.transform.GetChild(i);
                var position = coreCubePosition + childTransform.localPosition;
                var child = InstantiateCube(cubeType, position);
                child.transform.SetParent(coreCube.transform);
            }

            return coreCube;
        }
Example #7
0
    public void OnCollisionExit(Collision collision)
    {
        CubeType collidingType = collision.gameObject.GetComponent <CubeType>();

        if (type == null || collidingType.GetType() == type.GetType())
        {
            cubesOnTrigger.Remove(collidingType);
            if (cubesOnTrigger.Count == 0)
            {
                foreach (Triggerable triggerable in triggerables)
                {
                    triggerable.Untrigger();
                }
            }
        }
    }
Example #8
0
        public GameObject InstantiatePivotCube(CubeType cubeType)
        {
            switch (cubeType)
            {
                case CubeType.Ground:
                    return Instantiate<GameObject>(pivotGroundCubePrefab);

                case CubeType.Sand:
                    return Instantiate<GameObject>(pivotSandCubePrefab);

                case CubeType.Jump:
                    return Instantiate<GameObject>(pivotJumpCubePrefab);
            }

            return null;
        }
 public void SaveCubeType(string type)
 {
     using (var context = new ApplicationDbContext())
     {
         var cubeType = new CubeType(1, User.Identity.GetUserId(), type);
         context.CubeTypes.Add(cubeType);
         try
         {
             context.SaveChanges();
         }
         catch (Exception)
         {
             //pass
         }
     }
 }
Example #10
0
    public void cubePicked(CubeType pickedType)
    {
        //Debug.Log(activePlayer.ToString() + " has picked cube of type: " + pickedType.ToString());
        if(activePlayer == player1 && !activePlayer.GetComponent<PlayerScript>().isAI){
            if(player1Script.doDebugLogs)
                Debug.Log("human player 1 picked: " + pickedType);
            activePlayer = player2;
            player1Script.pickedACube(pickedType);

        }else if(activePlayer == player2 && !activePlayer.GetComponent<PlayerScript>().isAI){
            if(player2Script.doDebugLogs)
                Debug.Log("human player 2 picked: " + pickedType);
            activePlayer = player1;
            player2Script.pickedACube(pickedType);
        }
    }
Example #11
0
    // Slider


    private List <GameObject> DFS(List <GameObject> foundNeighbors, CubeType typeToSearch)
    {
        if (foundNeighbors.Contains(this.gameObject))
        {
            return(foundNeighbors);
        }
        if (this.cubeType != typeToSearch)
        {
            return(foundNeighbors);
        }
        foundNeighbors.Add(this.gameObject);
        foreach (GameObject neighbor in neighborCubes)
        {
            foundNeighbors = neighbor.GetComponent <Cube>().DFS(foundNeighbors, typeToSearch);
        }
        return(foundNeighbors);
    }
Example #12
0
    public Material GetMaterial(CubeType type)
    {
        switch (type)
        {
        case CubeType.Blue:
            return(blue);

        case CubeType.Red:
            return(red);

        case CubeType.Green:
            return(green);

        default:
            return(transparent);
        }
    }
Example #13
0
    public override void DisableBehaviour(string disableType)
    {
        Debug.Log("Disabling behaviour generic box; Setting kinematic to true");
        this.gameObject.GetComponent <Rigidbody>().isKinematic = true;
        float radius = radiusMultiplier * gameObject.transform.localScale.magnitude;

        Collider[] colliders = Physics.OverlapSphere(gameObject.transform.position, radius);
        foreach (Collider collider in colliders)
        {
            CubeType cube = collider.gameObject.GetComponent <CubeType>();
            if (cube != null && cube.gameObject != gameObject)
            {
                cube.TurnOn();
            }
        }
        GameObject.Destroy(disableSphereInstance);
        base.DisableBehaviour(disableType);
    }
Example #14
0
    // public override void Reset() {
    //   selfTransform.gameObject.SetActive(false);
    //   selfTransform.Translate(startPos - selfTransform.position);
    // }

    // ==========================================================================

    private void SetCubeType(Color color)
    {
        if (color == Color.red)
        {
            cubeType = CubeType.BALL;
        }
        else if (color == Color.yellow)
        {
            cubeType = CubeType.WALL;
        }
        else if (color == Color.green)
        {
            cubeType = CubeType.HEALTH;
        }
        else if (color == Color.cyan)
        {
            cubeType = CubeType.SCORE;
        }
    }
Example #15
0
        public static CubeType?IntersectType(CubeType original, CubeType intersector)
        {
            var pair = (a : original, b : intersector);

            return(pair switch
            {
                (CubeType.PosCube, CubeType.PosCube) => CubeType.NegCube,
                (CubeType.NegCube, CubeType.PosCube) => CubeType.PosCube,
                (CubeType.TurnOff, CubeType.PosCube) => null,

                (CubeType.PosCube, CubeType.NegCube) => throw new NotImplementedException(),
                (CubeType.NegCube, CubeType.NegCube) => throw new NotImplementedException(),
                (CubeType.TurnOff, CubeType.NegCube) => throw new NotImplementedException(),

                (CubeType.PosCube, CubeType.TurnOff) => CubeType.NegCube,
                (CubeType.NegCube, CubeType.TurnOff) => CubeType.PosCube,
                (CubeType.TurnOff, CubeType.TurnOff) => null,
                _ => throw new ArgumentOutOfRangeException()
            });
Example #16
0
    public void OnClickSpawnCube(CubeType cubeType, Vector3 pos)
    {
        for (int i = level.cubeDatas.Count; i-- > 0;)
        {
            if (level.cubeDatas[i].id == pos.ToString())
            {
                level.SetupCube(cubeType, pos);
                return;
            }
        }

        Debug.Log("spawn d'un item");

        CubeData cubeData = new CubeData();

        level.cubeDatas.Add(cubeData);

        level.SetupCube(cubeType, pos);
    }
Example #17
0
 // Update is called once per frame
 void Update()
 {
     if (isActive)
     {
         // Debug.Log("Laser is active");
         RaycastHit raycastHit;
         if (Physics.Raycast(hand.transform.position, hand.transform.forward, out raycastHit, MaximumDistance, TraceLayerMask))
         {
             GameObject target = raycastHit.collider.gameObject;
             //  Debug.Log("Raycast hit " + target);
             CubeType type = target.GetComponentInParent <CubeType>();
             targetIsCube = type != null;
             RenderLaser(target, raycastHit);
         }
         else
         {
             // Debug.Log("Raycast hit nothing");
         }
     }
 }
Example #18
0
 void DestroyStructure()
 {
     if (cubeTypes[currentBlockType].structures.Peek() != null)
     {
         if (!Gameplay.powered)
         {
             CubeType c = cubeTypes[currentBlockType];
             c.capacity += cubeTypes[currentBlockType].structures.Peek().GetComponent <StructureParent>().size;
             cubeTypes[currentBlockType] = c;
         }
         Destroy(cubeTypes[currentBlockType].structures.Peek());
         cubeTypes[currentBlockType].structures.Pop();
         if (cubeTypes[currentBlockType].maxCubes == 0 && !Gameplay.powered)
         {
             CubeType c = cubeTypes[currentBlockType];
             c.maxCubes = 4 < cubeTypes[currentBlockType].capacity ? 4 : cubeTypes[currentBlockType].capacity;
             cubeTypes[currentBlockType] = c;
         }
     }
 }
Example #19
0
        public void SpawnCube(SpawnCubeCommand command)
        {
            if (command.checkIfPositionAvailable)
            {
                foreach (var item in positionsLog)
                {
                    if (command.position == item)
                    {
                        if (cubes.TryGetValue(command.position, out Cube cube_))
                        {
                            cube_.TakeDamage(command.overkillDmg);
                        }
                        return;
                    }
                }
            }
            CubeType type = (CubeType)Random.Range(1, 7);
            //Debug.Log(type);
            int maxHp = ((int)type) * 3;

            //Debug.Log(maxHp);
            if (command.overkillDmg <= maxHp)
            {
                Cube tmp = Instantiate(command.cube, command.position, Quaternion.identity)
                           //.withID((ulong)((position.x + 1) * (position.z + 1) * (position.y + 1)))
                           .withSystem(this)
                           .withMaxHP(maxHp)
                           .withMaterial(materials[(int)type - 1])
                           .withType(type);
                AddCubeToList(tmp);
                tmp.transform.parent = this.transform;
                if (command.overkillDmg > 0 || !command.checkIfPositionAvailable)
                {
                    tmp.TakeDamage(command.overkillDmg); //THIS F***S THE APP LOL, NEVER DO THIS
                }
            }
            else
            {
                AddDestroyCubeCommandToBuffer(new DestroyCubeCommand(null, command.position, command.overkillDmg - maxHp));
            }
        }
Example #20
0
    IEnumerator SpawnInCube(RaycastHit hit, CubeType currentCubeType)
    {
        Vector3 cubePos = hit.collider.gameObject.transform.position;

        if (!currentCubeAboveGround)
        {
            yield return(new WaitForSeconds(0.05f));

            GameObject newCube = Instantiate(currentCubePrefab, cubePos, Quaternion.identity);
            newCube.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
            newCube.tag = "Floor";
        }

        if (currentCubeAboveGround)
        {
            yield return(new WaitForSeconds(0.05f));

            if (cubeType == CubeType.FENCE || cubeType == CubeType.FENCECORNER || cubeType == CubeType.FENCEEND)
            {
                GameObject newCube = Instantiate(currentCubePrefab, new Vector3(cubePos.x, -0.8799995f, cubePos.z), Quaternion.identity);
                newCube.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                newCube.transform.Rotate(transform.rotation.x, fiScript.woodRotation, transform.rotation.z);
                newCube.tag = "Floor";
                newCube.GetComponent <FenceCubeScript>().rotation = fiScript.woodRotation;
                if (cubeType == CubeType.FENCECORNER)
                {
                    newCube.GetComponent <FenceCubeScript>().type = FenceType.CORNER;
                }
                if (cubeType == CubeType.FENCEEND)
                {
                    newCube.GetComponent <FenceCubeScript>().type = FenceType.END;
                }
            }
            else
            {
                GameObject newCube = Instantiate(currentCubePrefab, new Vector3(cubePos.x, -0.8799995f, cubePos.z), Quaternion.identity);
                newCube.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                newCube.tag = "Floor";
            }
        }
    }
Example #21
0
    public void Spawn()
    {
        CubeType   nextType = ChooseType();
        GameObject cube;

        if (nextType == CubeType.Glass)
        {
            cube = (GameObject)Instantiate(
                glassCubePrefab);
        }
        else
        {
            cube = (GameObject)Instantiate(
                cubePrefab);
        }
        cube.GetComponent <CubeScript>().cubeManager = this;
        int index = Random.Range(0, cubeSpread);

        cube.GetComponent <CubeScript>().SetType(nextType);
        placeCube(cube, index);
    }
    // Applies current Cube Type, also calls refresh
    public void ApplyCubeType()
    {
        if (objectInteractionController == null)
        {
            objectInteractionController = FindObjectOfType <ObjectInteractionController>();
        }
        currentCubeType = objectInteractionController.GetCubeType();

        if (currentCubeType == null)
        {
            TargetChanged(); return;
        }
        if (currentCubeType.materials.Length != 6)
        {
            return;
        }
        for (int i = 0; i < 6; i++)
        {
            childMeshes[i].material = currentCubeType.materials[i];
        }
        TargetChanged();
    }
Example #23
0
    public void OnClickSpawnCube(CubeType cubeType, Vector3 pos)
    {
        for (int i = level.cubeDatas.Count; i-- > 0;)
        {
            if (level.cubeDatas[i].id == pos.ToString())
            {
                level.SetupCube(cubeType, pos);
                return;
            }
        }
        CubeData cubeData = new CubeData();

        cubeData.id       = pos.ToString();
        cubeData.cubeType = cubeType;
        cubeData.posX     = pos.x;
        cubeData.posY     = pos.y;
        cubeData.posZ     = pos.z;
        level.cubeDatas.Add(cubeData);

        level.SetupCube(cubeType, pos);

        SaveSystem.SaveLevel(level, "saveEditor");
    }
Example #24
0
 // Gets called only if the chunk is not loaded in saved data
 // Generation is delayed
 public IEnumerator GenerateChunk(ChunkPerlinOffsets chunkPerlinOffsets)
 {
     perlinOffsetX = chunkPerlinOffsets.chunkOffsetX;
     perlinOffsetZ = chunkPerlinOffsets.chunkOffsetZ;
     for (int x = 0; x < chunkHeight; x++)
     {
         for (int z = 0; z < chunkWidth; z++)
         {
             float columnHeight = GenerateHeight(x, z);
             for (int y = 0; y < columnHeight; y++)
             {
                 Vector3  newCubeLocation = transform.position + new Vector3(x, y, z) + generationOffset;
                 CubeType cubeType        = ProcessCubeType(y);
                 if (!cubeEditorTable.ContainsKey(newCubeLocation))
                 {
                     CreateCube(basicCubePrefab, newCubeLocation, cubeType);
                 }
             }
         }
         yield return(new WaitForSeconds(generationSeconds));
     }
     isLoaded = true;
 }
Example #25
0
    void Start()
    {
        cubeTransform = gameObject.transform;
        rb            = GetComponent <Rigidbody>();
        Debug.Log(rb.velocity);



        if (gameObject.tag == "FireCube")
        {
            cubeType = CubeType.Fire;
        }
        else if (gameObject.tag == "FrostCube")
        {
            cubeType = CubeType.Frost;
        }
        else if (gameObject.tag == "ArcaneCube")
        {
            cubeType = CubeType.Arcane;
        }

        Debug.Log(cubeType);
    }
        public void SwitchAid(ItemType type, CubeType matType)
        {
            currtType = type;
            GameObject newObj;
            string     itemName = Enum.GetName(typeof(ItemType), type);

            if (!BuildingManager.instance.currtItemIsPart)
            {
                newObj = GameObjectPool.instance.CreateObject("Cube", Resources.Load("Aid/CubeAid") as GameObject, transform.position, transform.rotation);
                if (newObj != prefabObj)
                {
                    GameObjectPool.instance.MyDestory(prefabObj);
                    prefabObj = newObj;
                }
                // 方块操作
                ChangeCubeMesh(itemName);
            }
            else
            {
                //配件操作
                newObj = GameObjectPool.instance.CreateObject(itemName, Resources.Load("Aid/" + itemName + "Aid") as GameObject, transform.position, transform.rotation);
                if (newObj != prefabObj)
                {
                    GameObjectPool.instance.MyDestory(prefabObj);
                    prefabObj = newObj;
                }
            }
            IObstacle = prefabObj.GetComponent <IAid>();

            //如果是第一次生成物体到对象池则进行归零化处理
            if (prefabObj.transform.parent == null)
            {
                prefabObj.transform.parent        = transform;
                prefabObj.transform.localPosition = Vector3.zero;
                prefabObj.transform.localRotation = Quaternion.identity;
            }
        }
Example #27
0
        private static Statistics GetStatistics(CubeType cubetype)
        {
            switch (cubetype)
            {
            case CubeType.TWO:
                return(statistics[0]);

                break;

            case CubeType.THREE:
                return(statistics[1]);

                break;

            case CubeType.FOUR:
                return(statistics[2]);

                break;

            default:
                throw new InvalidOperationException("Invalid cube type");
                break;
            }
        }
Example #28
0
        private static string CubeTypeToLabel(CubeType cubetype)
        {
            switch (cubetype)
            {
            case CubeType.TWO:
                return("2x2");

                break;

            case CubeType.THREE:
                return("3x3");

                break;

            case CubeType.FOUR:
                return("4x4");

                break;

            default:
                throw new InvalidOperationException("Unknown cube type");
                break;
            }
        }
Example #29
0
        /// <summary>
        /// Returns a scrambling strategy give a type of cube
        /// </summary>
        /// <param name="cubeType">Type of cube (example 3x3, 2x2)</param>
        /// <returns>Scrambling strategy</returns>
        private static IGenerateScrambleInterface CubeTypeToStrategy(CubeType cubeType)
        {
            IGenerateScrambleInterface strategy;

            switch (cubeType)
            {
            case CubeType.TWO:
                strategy = new TwoByTwoScramble();
                break;

            case CubeType.THREE:
                strategy = new ThreeByThreeScramble();
                break;

            case CubeType.FOUR:
                strategy = new FourByFourScramble();
                break;

            default:
                throw new InvalidOperationException("Unknown cube type");
                break;
            }
            return(strategy);
        }
Example #30
0
    //创建
    public virtual void Instance(ItemType type, CubeType cubeType)
    {
        size       = BuildingManager.instance.cubeSize;
        halfSize   = size / 2;
        mtype      = type;
        m_collider = GetComponent <Collider>();
        density    = PhysicsManager.GetDensity(cubeType);
        //如果是默认材质则不需要赋予材质
        if (cubeType == CubeType.none)
        {
            return;
        }

        transform.GetComponent <MeshRenderer>().material = CubeFactory.instance.GetCubeMaterial(cubeType);

        if (m_collider != null)
        {
            m_collider.material = CubeFactory.instance.GetCubePhysicMaterial(cubeType);
        }


        vol    = (transform.localScale.x * transform.localScale.y * transform.localScale.z);
        maxBuo = 1000 * 9.8f * vol;
    }
Example #31
0
            public Cuboid(string line)
            {
                var splitSpace = line.Split(" ");

                On = splitSpace.First() == "on";
                var coords = splitSpace[1].Split(",");
                var x      = coords[0].Split("=")[1].Split("..");

                x1 = int.Parse(x.First());
                x2 = int.Parse(x.Last());
                var y = coords[1].Split("=")[1].Split("..");

                y1 = int.Parse(y.First());
                y2 = int.Parse(y.Last());
                var z = coords[2].Split("=")[1].Split("..");

                z1 = int.Parse(z.First());
                z2 = int.Parse(z.Last());

                bool InBounds(int i) => i is >= -50 and <= 50;

                IsSmallEnoughForPart1 = InBounds(x1) && InBounds(x2) && InBounds(y1) & InBounds(y2) && InBounds(z1) && InBounds(z2);
                CubeType = On ? CubeType.PosCube : CubeType.TurnOff;
            }
Example #32
0
    void SolidifyTrail()
    {
        GameObject parent = Instantiate <GameObject>(structureParentPrefab);

        parent.GetComponent <StructureParent>().size = cubeTypes[currentBlockType].trail.ToArray().Length;

        foreach (GameObject trailCube in cubeTypes[currentBlockType].trail)
        {
            if (standardCapacity == 0)
            {
                return;
            }
            GameObject solidCube = Instantiate <GameObject>(cubeTypes[currentBlockType].solidPrefab);
            solidCube.transform.position         = trailCube.transform.position;
            solidCube.transform.localEulerAngles = new Vector3(0, 0, Mathf.Acos(direction.x) * 180 / Mathf.PI);
            solidCube.transform.parent           = parent.transform;
            Destroy(trailCube);
            CubeType c = cubeTypes[currentBlockType];
            if (!Gameplay.powered)
            {
                c.capacity--;
            }
            cubeTypes[currentBlockType] = c;
        }

        if (cubeTypes[currentBlockType].maxCubes > cubeTypes[currentBlockType].capacity)
        {
            CubeType c = cubeTypes[currentBlockType];
            c.maxCubes = cubeTypes[currentBlockType].capacity;
            cubeTypes[currentBlockType] = c;
        }

        cubeTypes[currentBlockType].structures.Push(parent);

        cubeTypes[currentBlockType].trail.Clear();
    }
Example #33
0
    public void SetCube(Vector3 pos, CubeType type)
    {
        int x = (int)pos.x;
        int y = (int)pos.y;
        int z = (int)pos.z;

        if (OutOfBound(x, y, z))
        {
            return;
        }

        if (type == CubeType.Stone)
        {
            cubes[x, y, z] = new Stone(pos, world);
        }
        else if (type == CubeType.Sand)
        {
            cubes[x, y, z] = new Sand(pos, world);
        }
        else if (type == CubeType.Ice)
        {
            cubes[x, y, z] = new Ice(pos, world);
        }
    }
Example #34
0
        // Experimental code.
        private static void CalculateSubtractedSlopes(CubeType[][][] cubic)
        {
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (int x = 0; x < xCount; x++)
            {
                for (int y = 0; y < yCount; y++)
                {
                    for (int z = 0; z < zCount; z++)
                    {
                        // TODO:
                        if (cubic[x][y][z] == CubeType.Cube)
                        {
                            // TODO:

                            if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, +1, +1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, -1, -1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeCenterFrontTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, +1, 0, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, -1, 0, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeLeftFrontCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, +1, 0, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, -1, 0, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeRightFrontCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, +1, -1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, -1, +1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeCenterFrontBottom;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 0, +1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, 0, -1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeLeftCenterTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, 0, +1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 0, -1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeRightCenterTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 0, -1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, 0, +1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeLeftCenterBottom;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, 0, -1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 0, +1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeRightCenterBottom;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, -1, +1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, +1, -1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeCenterBackTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, -1, 0, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, +1, 0, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeLeftBackCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, +1, -1, 0, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, +1, 0, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeRightBackCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, -1, -1, CubeType.Cube) &&
                                CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, +1, +1, CubeType.None))
                            {
                                cubic[x][y][z] = CubeType.SlopeCenterBackBottom;
                            }

                        }
                    }
                }
            }
        }
Example #35
0
    // Update is called once per frame
    void Update()
    {
        if (timeHit != -1 && Time.time - timeHit > 1f)
        {
            timeHit = -1;
        }

        if (PlayerMovement.S.elevator || timeHit != -1)
        {
            return;
        }

        Debug.DrawRay(transform.position, direction * .6f, Color.red);

        obstacle = CheckForObstacle();

        if (Input.GetButtonDown("X_P2"))
        {
            SolidifyTrail();
        }

        if (Input.GetButtonDown("Y_P2"))
        {
            DestroyStructure();
        }

        if (Input.GetAxis("LeftJoystickY_P2") == -1 && direction.y == 0)
        {
            direction = Vector3.up;
            change    = true;
        }

        if (Input.GetAxis("LeftJoystickY_P2") == 1 && direction.y == 0)
        {
            direction = Vector3.down;
            change    = true;
        }

        if (Input.GetAxis("LeftJoystickX_P2") == 1 && direction.x == 0)
        {
            direction = Vector3.right;
            change    = true;
        }

        if (Input.GetAxis("LeftJoystickX_P2") == -1 && direction.x == 0)
        {
            direction = Vector3.left;
            change    = true;
        }

        if (Input.GetAxis("LeftTrigger_P2") != 0 && Input.GetAxis("LeftTrigger_P2") != -1 && !incrementLeft && cubeTypes[currentBlockType].maxCubes > 1)
        {
            incrementLeft = true;
            CubeType c = cubeTypes[currentBlockType];
            c.maxCubes--;
            cubeTypes[currentBlockType] = c;
        }

        if (Input.GetAxis("RightTrigger_P2") != 0 && Input.GetAxis("RightTrigger_P2") != -1 &&
            !incrementRight && cubeTypes[currentBlockType].maxCubes < cubeTypes[currentBlockType].capacity && cubeTypes[currentBlockType].maxCubes < 10)
        {
            incrementRight = true;
            CubeType c = cubeTypes[currentBlockType];
            c.maxCubes++;
            cubeTypes[currentBlockType] = c;
        }


        if (Input.GetButtonDown("DPadUp_P2"))
        {
            if (!Gameplay.powered)
            {
                if (currentBlockIndex == 0)
                {
                    int prevCurrentBlockIndex = currentBlockIndex;

                    currentBlockIndex = availableBlocks.Length - 1;
                    while (!availableBlocks[currentBlockIndex])
                    {
                        currentBlockIndex--;
                    }

                    if (prevCurrentBlockIndex != currentBlockIndex)
                    {
                        ClearTrail();
                    }
                }
                else if (availableBlocks[currentBlockIndex - 1])
                {
                    ClearTrail();
                    currentBlockIndex -= 1;
                }
            }
            else
            {
                if (currentBlockIndex == 0)
                {
                    currentBlockIndex = availableBlocks.Length - 1;
                }
                else
                {
                    currentBlockIndex--;
                }
            }

            currentBlockType = cubeTypeStrings[currentBlockIndex];
        }


        if (Input.GetButtonDown("DPadDown_P2"))
        {
            if (!Gameplay.powered)
            {
                if (currentBlockIndex == availableBlocks.Length - 1 || !availableBlocks[currentBlockIndex + 1])
                {
                    ClearTrail();
                    currentBlockIndex = 0;
                }
                else if (availableBlocks[currentBlockIndex + 1])
                {
                    ClearTrail();
                    currentBlockIndex += 1;
                }
            }
            else
            {
                if (currentBlockIndex == availableBlocks.Length - 1)
                {
                    currentBlockIndex = 0;
                }
                else
                {
                    currentBlockIndex++;
                }
            }

            currentBlockType = cubeTypeStrings[currentBlockIndex];
        }

        if ((Input.GetAxis("LeftTrigger_P2") == 0 || Input.GetAxis("LeftTrigger_P2") == -1) && incrementLeft)
        {
            incrementLeft = false;
        }

        if ((Input.GetAxis("RightTrigger_P2") == 0 || Input.GetAxis("RightTrigger_P2") == -1) && incrementRight)
        {
            incrementRight = false;
        }

        if (change)
        {
            timeStart = Time.time - speed;
            change    = false;
        }

        if (cubeTypes[currentBlockType].maxCubes > cubeTypes[currentBlockType].capacity)
        {
            CubeType c = cubeTypes[currentBlockType];
            c.maxCubes = cubeTypes[currentBlockType].capacity;
            cubeTypes[currentBlockType] = c;
        }
        else if (cubeTypes[currentBlockType].maxCubes == 0 && cubeTypes[currentBlockType].maxCubes < cubeTypes[currentBlockType].capacity)
        {
            CubeType c = cubeTypes[currentBlockType];
            c.maxCubes = 4 < cubeTypes[currentBlockType].capacity ? 4 : cubeTypes[currentBlockType].capacity;
            cubeTypes[currentBlockType] = c;
        }

        if (Time.time - timeStart >= speed)
        {
            Move();
            CreateTrailCube();
        }

        if (!Gameplay.powered)
        {
            blockType.text   = currentBlockType;
            capacity.text    = cubeTypes[currentBlockType].capacity.ToString();
            trailLength.text = cubeTypes[currentBlockType].maxCubes.ToString();
        }
        else
        {
            blockType.text   = currentBlockType;
            capacity.text    = "INF";
            trailLength.text = "INF";
        }
    }
Example #36
0
        public static SerializableBlockOrientation GetCubeOrientation(CubeType type)
        {
            if (CubeOrientations.ContainsKey(type))
                return CubeOrientations[type];

            throw new NotImplementedException(string.Format("SetCubeOrientation of type [{0}] not yet implemented.", type));
        }
Example #37
0
 static void addCube(Color c, CubeType type, bool removable, BlockingType blocking, uint texture, string name, string description, VertexAwesome[] mesh)
 {
     add(new BlockType
     {
         Schematic = c,
         Name = name,
         Description = description,
         IsCube = true,
         IsEmpty = type == CubeType.Empty,
         IsSolid = type == CubeType.Solid,
         Removable = removable,
         Blocking = blocking,
         Texture = texture,
         //Mesh = mesh
     });
 }
Example #38
0
 static void addCube(Color c, CubeType type, bool removable, BlockingType blocking, uint texture, string name, string description)
 {
     addCube(c, type, removable, blocking, texture, name, description, null);
 }
Example #39
0
        private static bool CheckAdjacentCubic3(CubeType[][][] ccubic, int x, int y, int z, int xCount, int yCount, int zCount,
            int xDelta1, int yDelta1, int zDelta1, CubeType cubeType1,
            int xDelta2, int yDelta2, int zDelta2, CubeType cubeType2,
            int xDelta3, int yDelta3, int zDelta3, CubeType cubeType3)
        {
            if (IsValidRange(x, y, z, xCount, yCount, zCount, xDelta1, yDelta1, zDelta1)
                && IsValidRange(x, y, z, xCount, yCount, zCount, xDelta2, yDelta2, zDelta2)
                && IsValidRange(x, y, z, xCount, yCount, zCount, xDelta3, yDelta3, zDelta3))
            {
                return ccubic[x + xDelta1][y + yDelta1][z + zDelta1] == cubeType1
                    && ccubic[x + xDelta2][y + yDelta2][z + zDelta2] == cubeType2
                    && ccubic[x + xDelta3][y + yDelta3][z + zDelta3] == cubeType3;
            }

            return false;
        }
Example #40
0
    public void PlayCubeSpawn(CubeType cubeType)
    {
        if (cubeType != CubeType.NUCLEAR)
        {
            audio.pitch = Random.Range(-2f, 1f);
        }
        else
        {
            audio.pitch = Random.Range(1.5f, 3f);
        }

        audio.volume = GameObject.Find("GameData").GetComponent <GameData>().cubePlacementAudioLevel;


        if (cubeType == CubeType.FIRE)
        {
            if (!audio.isPlaying)
            {
                audio.PlayOneShot(fireClip);
            }
        }

        if (cubeType == CubeType.WOOD)
        {
            if (!audio.isPlaying)
            {
                audio.PlayOneShot(woodClip);
            }
        }

        if (cubeType == CubeType.PAVING)
        {
            audio.PlayOneShot(pavingClip);
        }

        if (cubeType == CubeType.WATER)
        {
            audio.PlayOneShot(waterClip);
        }

        if (cubeType == CubeType.STONE)
        {
            audio.PlayOneShot(stoneClip);
        }

        if (cubeType == CubeType.TREE)
        {
            audio.PlayOneShot(treeClip);
        }

        if (cubeType == CubeType.LONGGRASS)
        {
            audio.PlayOneShot(grassClip);
        }

        if (cubeType == CubeType.SAND)
        {
            audio.PlayOneShot(sandClip);
        }

        if (cubeType == CubeType.SNOW)
        {
            audio.PlayOneShot(snowClip);
        }

        if (cubeType == CubeType.LANTERN)
        {
            audio.PlayOneShot(lanternClip);
        }

        if (cubeType == CubeType.DIRT)
        {
            audio.PlayOneShot(dirtClip);
        }

        if (cubeType == CubeType.LILYPAD)
        {
            audio.PlayOneShot(lilypadClip);
        }

        if (cubeType == CubeType.NUCLEAR)
        {
            audio.PlayOneShot(waterClip);
        }

        if (cubeType == CubeType.FLOWER)
        {
            if (!audio.isPlaying)
            {
                audio.PlayOneShot(flowerClip);
            }
        }
    }
Example #41
0
        public static Dictionary<CubeType, int> CountCubic(CubeType[][][] cubic)
        {
            var assetCount = new Dictionary<CubeType, int>();
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (var x = 0; x < xCount; x++)
            {
                var cx = cubic[x];
                for (var y = 0; y < yCount; y++)
                {
                    var cy = cx[y];
                    for (var z = 0; z < zCount; z++)
                    {
                        if (assetCount.ContainsKey(cy[z]))
                        {
                            assetCount[cy[z]]++;
                        }
                        else
                        {
                            assetCount.Add(cy[z], 1);
                        }
                    }
                }
            }

            return assetCount;
        }
Example #42
0
        private static void CalculateAddedCorners(CubeType[][][] cubic, Action incrementProgress)
        {
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (var x = 0; x < xCount; x++)
            {
                for (var y = 0; y < yCount; y++)
                {
                    for (var z = 0; z < zCount; z++)
                    {
                        if (incrementProgress != null)
                        {
                            incrementProgress.Invoke();
                        }

                        if (cubic[x][y][z] == CubeType.None)
                        {
                            if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeLeftFrontCenter, -1, 0, 0, CubeType.SlopeCenterFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeLeftFrontCenter, 0, +1, 0, CubeType.SlopeLeftCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontTop, 0, +1, 0, CubeType.SlopeLeftCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, +1, 0, CubeType.InverseCornerRightBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontTop, 0, +1, 0, CubeType.InverseCornerRightBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, +1, 0, CubeType.SlopeLeftCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontTop, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.SlopeLeftFrontCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.SlopeLeftCenterTop, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.SlopeLeftFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftFrontTop;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeRightFrontCenter, +1, 0, 0, CubeType.SlopeCenterFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeRightFrontCenter, 0, +1, 0, CubeType.SlopeRightCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontTop, 0, +1, 0, CubeType.SlopeRightCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, +1, 0, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontTop, 0, +1, 0, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, +1, 0, CubeType.SlopeRightCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontTop, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.SlopeRightFrontCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.SlopeRightCenterTop, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.SlopeRightFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightFrontTop;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeLeftFrontCenter, -1, 0, 0, CubeType.SlopeCenterFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeLeftFrontCenter, 0, +1, 0, CubeType.SlopeLeftCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, +1, 0, CubeType.SlopeLeftCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, +1, 0, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, +1, 0, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, +1, 0, CubeType.SlopeLeftCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.SlopeLeftFrontCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.SlopeLeftCenterBottom, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.SlopeLeftFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftFrontBottom;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeRightFrontCenter, +1, 0, 0, CubeType.SlopeCenterFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeRightFrontCenter, 0, +1, 0, CubeType.SlopeRightCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, +1, 0, CubeType.SlopeRightCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, +1, 0, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, +1, 0, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, +1, 0, CubeType.SlopeRightCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.SlopeRightFrontCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.SlopeRightCenterBottom, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, +1, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.SlopeRightFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightFrontBottom;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeLeftBackCenter, -1, 0, 0, CubeType.SlopeCenterBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeLeftBackCenter, 0, -1, 0, CubeType.SlopeLeftCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackTop, 0, -1, 0, CubeType.SlopeLeftCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, -1, 0, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackTop, 0, -1, 0, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, -1, 0, CubeType.SlopeLeftCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackTop, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.SlopeLeftBackCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.SlopeLeftCenterTop, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.SlopeLeftBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftBackTop;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeRightBackCenter, +1, 0, 0, CubeType.SlopeCenterBackTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, +1, CubeType.SlopeRightBackCenter, 0, -1, 0, CubeType.SlopeRightCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackTop, 0, -1, 0, CubeType.SlopeRightCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackTop, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, -1, 0, CubeType.SlopeRightCenterTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackTop, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.SlopeRightBackCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.SlopeRightCenterTop, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.SlopeRightBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightBackTop;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeLeftBackCenter, -1, 0, 0, CubeType.SlopeCenterBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeLeftBackCenter, 0, -1, 0, CubeType.SlopeLeftCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackBottom, 0, -1, 0, CubeType.SlopeLeftCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, -1, 0, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackBottom, 0, -1, 0, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, -1, 0, CubeType.SlopeLeftCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackBottom, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.SlopeLeftBackCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.SlopeLeftCenterBottom, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.SlopeLeftBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftBackBottom;
                            }
                            else if (CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeRightBackCenter, +1, 0, 0, CubeType.SlopeCenterBackBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, 0, -1, CubeType.SlopeRightBackCenter, 0, -1, 0, CubeType.SlopeRightCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackBottom, 0, -1, 0, CubeType.SlopeRightCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, -1, 0, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackBottom, 0, -1, 0, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, -1, 0, CubeType.SlopeRightCenterBottom) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackBottom, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.SlopeRightBackCenter) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.SlopeRightCenterBottom, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic2(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.SlopeRightBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightBackBottom;
                            }


                            // ########### Triplet checks
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, -1, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackBottom, 0, -1, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, -1, 0, CubeType.SlopeRightCenterBottom, 0, 0, -1, CubeType.InverseCornerLeftFrontTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontTop, 0, -1, 0, CubeType.InverseCornerLeftFrontTop, 0, 0, -1, CubeType.SlopeRightBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightBackBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, +1, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                  CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontTop, 0, +1, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                  CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, +1, 0, CubeType.SlopeLeftCenterTop, 0, 0, +1, CubeType.InverseCornerRightBackBottom) ||
                                  CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackBottom, 0, +1, 0, CubeType.InverseCornerRightBackBottom, 0, 0, +1, CubeType.SlopeLeftFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftFrontTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, -1, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackBottom, 0, -1, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, -1, 0, CubeType.SlopeLeftCenterBottom, 0, 0, -1, CubeType.InverseCornerRightFrontTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontTop, 0, -1, 0, CubeType.InverseCornerRightFrontTop, 0, 0, -1, CubeType.SlopeLeftBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftBackBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, +1, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontTop, 0, +1, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, +1, 0, CubeType.SlopeRightCenterTop, 0, 0, +1, CubeType.InverseCornerLeftBackBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackBottom, 0, +1, 0, CubeType.InverseCornerLeftBackBottom, 0, 0, +1, CubeType.SlopeRightFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightFrontTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, +1, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, +1, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, +1, 0, CubeType.SlopeRightCenterBottom, 0, 0, -1, CubeType.InverseCornerLeftBackTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftBackTop, 0, +1, 0, CubeType.InverseCornerLeftBackTop, 0, 0, -1, CubeType.SlopeRightFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightFrontBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, -1, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterBackTop, 0, -1, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, -1, 0, CubeType.SlopeLeftCenterTop, 0, 0, +1, CubeType.InverseCornerRightFrontBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightFrontBottom, 0, -1, 0, CubeType.InverseCornerRightFrontBottom, 0, 0, +1, CubeType.SlopeLeftBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftBackTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, +1, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.SlopeCenterFrontBottom, 0, +1, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, +1, 0, CubeType.SlopeLeftCenterBottom, 0, 0, -1, CubeType.InverseCornerRightBackTop) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.InverseCornerRightBackTop, 0, +1, 0, CubeType.InverseCornerRightBackTop, 0, 0, -1, CubeType.SlopeLeftFrontCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerLeftFrontBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.SlopeCenterBackTop, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, -1, 0, CubeType.SlopeRightCenterTop, 0, 0, +1, CubeType.InverseCornerLeftFrontBottom) ||
                                CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.InverseCornerLeftFrontBottom, 0, -1, 0, CubeType.InverseCornerLeftFrontBottom, 0, 0, +1, CubeType.SlopeRightBackCenter))
                            {
                                cubic[x][y][z] = CubeType.NormalCornerRightBackTop;
                            }
                        }
                    }
                }
            }
        }
Example #43
0
        private static bool CheckAdjacentCubic(CubeType[][][] ccubic, int x, int y, int z, int xCount, int yCount, int zCount, int xDelta, int yDelta, int zDelta, CubeType cubeType)
        {
            if (IsValidRange(x, y, z, xCount, yCount, zCount, xDelta, yDelta, zDelta))
            {
                if (xDelta != 0 && ccubic[x + xDelta][y][z] == cubeType &&
                    yDelta != 0 && ccubic[x][y + yDelta][z] == cubeType &&
                    zDelta == 0)
                {
                    return true;
                }

                if (xDelta != 0 && ccubic[x + xDelta][y][z] == cubeType &&
                    yDelta == 0 &&
                    zDelta != 0 && ccubic[x][y][z + zDelta] == cubeType)
                {
                    return true;
                }

                if (xDelta == 0 &&
                    yDelta != 0 && ccubic[x][y + yDelta][z] == cubeType &&
                    zDelta != 0 && ccubic[x][y][z + zDelta] == cubeType)
                {
                    return true;
                }

                if (xDelta != 0 && ccubic[x + xDelta][y][z] == cubeType &&
                    yDelta != 0 && ccubic[x][y + yDelta][z] == cubeType &&
                    zDelta != 0 && ccubic[x][y][z + zDelta] == cubeType)
                {
                    return true;
                }
            }

            return false;
        }
Example #44
0
    public void Reset()
    {
        updatePreviousCubePicks();
        hasPickedACube = false;

        previousCube = pickedCube;
        instantiatePrevCube();
        pickedCube = CubeType.none;
    }
Example #45
0
 public void pickedACube(CubeType pickedType)
 {
     pickedCube = pickedType;
     //updatePreviousCubePicks(pickedCube);
     hasPickedACube = true;
 }
Example #46
0
    // Registers a set of actions with predictor, updating
    // its data. We assume actions has exactly nValue
    // elements in it.
    public void registerSequence(CubeType[] actions)
    {
        double startTime = Time.realtimeSinceStartup;

        if(actions.Length != nValue){
            Debug.Log("actions.Length != nValue");
            Debug.Break();
        }

        // Split the sequence into a key and value for the Hashtable
        CubeType[] previousActions = new CubeType[nValue-1];
        for (int i = 0; i < nValue-1; i++)
        {
            previousActions[i] = actions[i];
        }

        CubeType currentAction = actions[nValue-1];

        keyStringOfArray = "";
        keyStringOfArray = returnStringName(previousActions);
        if(doDebugLogs)
            Debug.Log(playerThisNgramPredictorBelongsTo +  "registered sequence: " + keyStringOfArray + " + " + currentAction);

        if (!data.ContainsKey(keyStringOfArray))
        {
            data[keyStringOfArray] = new KeyDataRecord();
        }

        // Get the correct data structure
        KeyDataRecord keyData = (KeyDataRecord)data[keyStringOfArray];

        if (keyData.counts == null)
            keyData.counts = new Hashtable();

        // Make sure we have a record for the follow on value
        if(!keyData.counts.ContainsKey(currentAction))
            keyData.counts[currentAction] = 0;

        // Add to the total, and to the count for the value
        keyData.counts[currentAction] = (int)keyData.counts[currentAction] + 1;
        keyData.total += 1;

        data[keyStringOfArray] = keyData;

        double temp = Time.realtimeSinceStartup-startTime;
        overallTimeTakenForRegistering += temp;
        overallRegisters++;
        averageTimeTakenForRegistering = overallTimeTakenForRegistering / overallRegisters;
    }
Example #47
0
    private void UpdatePath()
    {
        groundDetected = false;

        vertexList.Clear(); // delete all previouse vertices


        velocity = Quaternion.AngleAxis(-teleportArcAngle, transform.right) * transform.forward * strength;

        RaycastHit hit;


        Vector3 pos = transform.position; // take off position

        vertexList.Add(pos);

        while (!groundDetected && vertexList.Count < maxVertexcount)
        {
            Vector3 newPos = pos + velocity * vertexDelta
                             + 0.5f * Physics.gravity * vertexDelta * vertexDelta;

            velocity += Physics.gravity * vertexDelta;

            vertexList.Add(newPos); // add new calculated vertex

            // linecast between last vertex and current vertex
            if (Physics.Linecast(pos, newPos, out hit, ~excludeLayers))
            {
                groundPos  = hit.point;
                lastNormal = hit.normal;
                // Debug.Log("Hit normal: " + hit.normal);
                //Debug.Log("Angle between hit normal and (0,1,0): " + Vector3.Angle(hit.normal, new Vector3(0,1,0)));
                //Debug.Log("Is it less than maximum landable angle? " + (Math.Abs(Vector3.Angle(hit.normal, new Vector3(0, 1, 0))) < maximumLandableAngle));
                canTeleport    = Math.Abs(Vector3.Angle(hit.normal, new Vector3(0, 1, 0))) < maximumLandableAngle;
                cubeTarget     = hit.transform.gameObject.GetComponent <CubeType>();
                groundDetected = true;
            }
            pos = newPos; // update current vertex as last vertex
        }



        positionMarker.transform.position = groundPos + lastNormal * distanceFromSurface;
        positionMarker.transform.LookAt(groundPos);
        invalidPositionMarker.transform.position = groundPos + lastNormal * distanceFromSurface;
        invalidPositionMarker.transform.LookAt(groundPos);

        if (groundDetected && canTeleport)
        {
            positionMarker.SetActive(true);
            invalidPositionMarker.SetActive(false);
        }
        if (groundDetected && !canTeleport)
        {
            invalidPositionMarker.SetActive(true);
            positionMarker.SetActive(false);
        }
        if (!groundDetected)
        {
            positionMarker.SetActive(false);
            invalidPositionMarker.SetActive(false);
        }

        // Update Line Renderer

        arcRenderer.positionCount = vertexList.Count;
        arcRenderer.SetPositions(vertexList.ToArray());
        arcRenderer.enabled = true;
    }
Example #48
0
    // Use this for initialization
    void Start()
    {
        previousCube = CubeType.none;
        gameLogicScript = GameObject.Find("GameLogic").GetComponent<gamelogic>();

        if(isAINgram){
            ngramPredictor = new NGramPredictor();
            ngramPredictor.Start();
            ngramPredictor.nValue = NgramWindowSize + 1;
            ngramPredictor.doDebugLogs = doDebugLogs;
            ngramPredictor.playerThisNgramPredictorBelongsTo = this.gameObject.ToString();
        }

        otherPlayerScript = gameLogicScript.returnOtherPlayer(this);
        //track previous actions if other player uses ngrams
        if(otherPlayerScript.isAINgram){
            previousCubePicks = new CubeType[otherPlayerScript.NgramWindowSize + 1];

            for (int i = 0; i < previousCubePicks.Length; i++)
                previousCubePicks[i] = CubeType.none;
        }
    }
Example #49
0
        // Experimental code.
        private static void CalculateSubtractedInverseCorners(CubeType[][][] cubic)
        {
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (int x = 0; x < xCount; x++)
            {
                for (int y = 0; y < yCount; y++)
                {
                    for (int z = 0; z < zCount; z++)
                    {
                        // TODO:
                    }
                }
            }
        }
 public CubeDescription(CubeType type)
 {
     this.type = type;
     dir       = Direction.West;
     value     = 400;
 }
Example #51
0
        public static void CrawlExterior(CubeType[][][] cubic)
        {
            // TODO: multi-thread this entire method, as it is the slowest to run for large arrays.

            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            var list = new Queue<Vector3I>();

            // Add basic check points from the corner blocks.
            if (cubic[0][0][0] == CubeType.None)
                list.Enqueue(new Vector3I(0, 0, 0));
            if (cubic[xCount - 1][0][0] == CubeType.None)
                list.Enqueue(new Vector3I(xCount - 1, 0, 0));
            if (cubic[0][yCount - 1][0] == CubeType.None)
                list.Enqueue(new Vector3I(0, yCount - 1, 0));
            if (cubic[0][0][zCount - 1] == CubeType.None)
                list.Enqueue(new Vector3I(0, 0, zCount - 1));
            if (cubic[xCount - 1][yCount - 1][0] == CubeType.None)
                list.Enqueue(new Vector3I(xCount - 1, yCount - 1, 0));
            if (cubic[0][yCount - 1][zCount - 1] == CubeType.None)
                list.Enqueue(new Vector3I(0, yCount - 1, zCount - 1));
            if (cubic[xCount - 1][0][zCount - 1] == CubeType.None)
                list.Enqueue(new Vector3I(xCount - 1, 0, zCount - 1));
            if (cubic[xCount - 1][yCount - 1][zCount - 1] == CubeType.None)
                list.Enqueue(new Vector3I(xCount - 1, yCount - 1, zCount - 1));

            while (list.Count > 0)
            {
                var item = list.Dequeue();

                if (cubic[item.X][item.Y][item.Z] == CubeType.None)
                {
                    cubic[item.X][item.Y][item.Z] = CubeType.Exterior;

                    if (item.X - 1 >= 0 && item.Y >= 0 && item.Z >= 0 && item.X - 1 < xCount && item.Y < yCount && item.Z < zCount && cubic[item.X - 1][item.Y][item.Z] == CubeType.None)
                    {
                        list.Enqueue(new Vector3I(item.X - 1, item.Y, item.Z));
                    }
                    if (item.X >= 0 && item.Y - 1 >= 0 && item.Z >= 0 && item.X < xCount && item.Y - 1 < yCount && item.Z < zCount && cubic[item.X][item.Y - 1][item.Z] == CubeType.None)
                    {
                        list.Enqueue(new Vector3I(item.X, item.Y - 1, item.Z));
                    }
                    if (item.X >= 0 && item.Y >= 0 && item.Z - 1 >= 0 && item.X < xCount && item.Y < yCount && item.Z - 1 < zCount && cubic[item.X][item.Y][item.Z - 1] == CubeType.None)
                    {
                        list.Enqueue(new Vector3I(item.X, item.Y, item.Z - 1));
                    }
                    if (item.X + 1 >= 0 && item.Y >= 0 && item.Z >= 0 && item.X + 1 < xCount && item.Y < yCount && item.Z < zCount && cubic[item.X + 1][item.Y][item.Z] == CubeType.None)
                    {
                        list.Enqueue(new Vector3I(item.X + 1, item.Y, item.Z));
                    }
                    if (item.X >= 0 && item.Y + 1 >= 0 && item.Z >= 0 && item.X < xCount && item.Y + 1 < yCount && item.Z < zCount && cubic[item.X][item.Y + 1][item.Z] == CubeType.None)
                    {
                        list.Enqueue(new Vector3I(item.X, item.Y + 1, item.Z));
                    }
                    if (item.X >= 0 && item.Y >= 0 && item.Z + 1 >= 0 && item.X < xCount && item.Y < yCount && item.Z + 1 < zCount && cubic[item.X][item.Y][item.Z + 1] == CubeType.None)
                    {
                        list.Enqueue(new Vector3I(item.X, item.Y, item.Z + 1));
                    }
                }
            }

            // switch values around to work with current enum logic.
            for (var x = 0; x < xCount; x++)
            {
                var cx = cubic[x];
                for (var y = 0; y < yCount; y++)
                {
                    var cy = cx[y];
                    for (var z = 0; z < zCount; z++)
                    {
                        if (cy[z] == CubeType.None)
                            cy[z] = CubeType.Interior;
                        else if (cy[z] == CubeType.Exterior)
                            cy[z] = CubeType.None;
                    }
                }
            }
        }
 public CubeDescription(CubeType type, Direction dir)
 {
     this.type = type;
     this.dir  = dir;
     value     = 400;
 }
Example #53
0
        private static void CalculateAddedSlopes(CubeType[][][] cubic, Action incrementProgress)
        {
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (var x = 0; x < xCount; x++)
            {
                var cx = cubic[x];
                for (var y = 0; y < yCount; y++)
                {
                    var cy = cx[y];
                    for (var z = 0; z < zCount; z++)
                    {
                        if (incrementProgress != null)
                        {
                            incrementProgress.Invoke();
                        }

                        if (cy[z] == CubeType.None)
                        {
                            if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, 1, 1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeCenterFrontTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 1, 0, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeLeftFrontCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 1, 1, 0, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeRightFrontCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, 1, -1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeCenterFrontBottom;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeLeftCenterTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 1, 0, 1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeRightCenterTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, 0, -1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeLeftCenterBottom;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 1, 0, -1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeRightCenterBottom;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, -1, 1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeCenterBackTop;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, -1, -1, 0, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeLeftBackCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 1, -1, 0, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeRightBackCenter;
                            }
                            else if (CheckAdjacentCubic(cubic, x, y, z, xCount, yCount, zCount, 0, -1, -1, CubeType.Cube))
                            {
                                cy[z] = CubeType.SlopeCenterBackBottom;
                            }
                        }
                    }
                }
            }
        }
Example #54
0
    CubeType[] getOtherPlayersLastActions()
    {
        CubeType[] lastActions = new CubeType[ngramPredictor.nValue - 1]; //lastactions are the previous actions without the current one
        for (int i = 0; i < ngramPredictor.nValue - 1; i++)
            lastActions[i] = otherPlayerScript.previousCubePicks[i+1];

        return lastActions;
    }
Example #55
0
        private static void CalculateAddedInverseCorners(CubeType[][][] cubic, Action incrementProgress)
        {
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (var x = 0; x < xCount; x++)
            {
                for (var y = 0; y < yCount; y++)
                {
                    for (var z = 0; z < zCount; z++)
                    {
                        if (incrementProgress != null)
                        {
                            incrementProgress.Invoke();
                        }

                        if (cubic[x][y][z] == CubeType.None)
                        {
                            if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.Cube, 0, -1, 0, CubeType.Cube, 0, 0, -1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerLeftFrontTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.Cube, 0, +1, 0, CubeType.Cube, 0, 0, -1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerRightBackTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.Cube, 0, +1, 0, CubeType.Cube, 0, 0, -1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerLeftBackTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.Cube, 0, -1, 0, CubeType.Cube, 0, 0, -1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerRightFrontTop;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.Cube, 0, +1, 0, CubeType.Cube, 0, 0, +1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerLeftBackBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.Cube, 0, +1, 0, CubeType.Cube, 0, 0, +1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerRightBackBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, +1, 0, 0, CubeType.Cube, 0, -1, 0, CubeType.Cube, 0, 0, +1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerLeftFrontBottom;
                            }
                            else if (CheckAdjacentCubic3(cubic, x, y, z, xCount, yCount, zCount, -1, 0, 0, CubeType.Cube, 0, -1, 0, CubeType.Cube, 0, 0, +1, CubeType.Cube))
                            {
                                cubic[x][y][z] = CubeType.InverseCornerRightFrontBottom;
                            }
                        }
                    }
                }
            }
        }
Example #56
0
    private void pickCubeByNGramAI()
    {
        CubeType predictedOtherPlayerPick = ngramPredictor.getMostLikely(getOtherPlayersLastActions());
        if(doDebugLogs)
            Debug.Log(transform.gameObject.ToString() + " predicted: " + predictedOtherPlayerPick);

        //if no prediction was made, make a random guess
        if(predictedOtherPlayerPick == CubeType.none){
            pickedCube = (CubeType)Random.Range(0, 5);
            if(doDebugLogs)
                Debug.Log(transform.gameObject.ToString() + " picked Cube by Ngram, fallback to random: " + pickedCube);
        }
        else{
            pickedCube = pickCounterCube(predictedOtherPlayerPick);
            if(doDebugLogs)
                Debug.Log(transform.gameObject.ToString() + " picked Cube by Ngram, counter picked: " + pickedCube);
        }

        //updatePreviousCubePicks(pickedCube);
        hasPickedACube = true;
    }
Example #57
0
        private static bool CheckAdjacentCubic1(CubeType[][][] ccubic, int x, int y, int z, int xCount, int yCount, int zCount,
           int xDelta, int yDelta, int zDelta, CubeType cubeType)
        {
            if (IsValidRange(x, y, z, xCount, yCount, zCount, xDelta, yDelta, zDelta))
            {
                return ccubic[x + xDelta][y + yDelta][z + zDelta] == cubeType;
            }

            return false;
        }
Example #58
0
    private void pickCubeByPattern()
    {
        switch(previousCube) {
            case CubeType.red:
                pickedCube = CubeType.blue;
                break;
            case CubeType.blue:
                pickedCube = CubeType.green;
                break;
            case CubeType.green:
                pickedCube = CubeType.black;
                break;
            case CubeType.black:
                pickedCube = CubeType.white;
                break;
            case CubeType.white:
                pickedCube = CubeType.red;
                break;
            case CubeType.none:
                pickedCube = CubeType.red;
                break;
            default:
                Debug.Log("default called, something went wrong");
                Debug.Break();
                pickedCube = CubeType.red;
                break;
        }
        if(doDebugLogs)
            Debug.Log(transform.gameObject.ToString() +  " picked Cube By Pattern: " + pickedCube);

        //updatePreviousCubePicks(pickedCube);
        hasPickedACube = true;
    }
Example #59
0
        internal static void BuildStructureFromCubic(MyObjectBuilder_CubeGrid entity, CubeType[][][] cubic, bool fillObject, SubtypeId blockType, SubtypeId slopeBlockType, SubtypeId cornerBlockType, SubtypeId inverseCornerBlockType)
        {
            var xCount = cubic.Length;
            var yCount = cubic[0].Length;
            var zCount = cubic[0][0].Length;

            for (var x = 0; x < xCount; x++)
            {
                for (var y = 0; y < yCount; y++)
                {
                    for (var z = 0; z < zCount; z++)
                    {
                        if ((cubic[x][y][z] != CubeType.None && cubic[x][y][z] != CubeType.Interior) ||
                            (cubic[x][y][z] == CubeType.Interior && fillObject))
                        {
                            MyObjectBuilder_CubeBlock newCube;
                            entity.CubeBlocks.Add(newCube = new MyObjectBuilder_CubeBlock());

                            if (cubic[x][y][z].ToString().StartsWith("Cube"))
                            {
                                newCube.SubtypeName = blockType.ToString();
                            }
                            else if (cubic[x][y][z].ToString().StartsWith("Slope"))
                            {
                                newCube.SubtypeName = slopeBlockType.ToString();
                            }
                            else if (cubic[x][y][z].ToString().StartsWith("NormalCorner"))
                            {
                                newCube.SubtypeName = cornerBlockType.ToString();
                            }
                            else if (cubic[x][y][z].ToString().StartsWith("InverseCorner"))
                            {
                                newCube.SubtypeName = inverseCornerBlockType.ToString();
                            }
                            else if (cubic[x][y][z] == CubeType.Interior && fillObject)
                            {
                                newCube.SubtypeName = blockType.ToString();
                                cubic[x][y][z] = CubeType.Cube;
                            }

                            newCube.EntityId = 0;
                            newCube.BlockOrientation = GetCubeOrientation(cubic[x][y][z]);
                            newCube.Min = new Vector3I(x, y, z);
                        }
                    }
                }
            }
        }
Example #60
0
    private void pickCubeByRandom()
    {
        pickedCube = (CubeType)Random.Range(0, 5);
        if(doDebugLogs)
            Debug.Log(transform.gameObject.ToString() +  " picked Cube By Random: " + pickedCube);

        //updatePreviousCubePicks(pickedCube);
        hasPickedACube = true;
    }