예제 #1
0
 public void ClearHover()
 {
     if(state != CubeState.Selected)
     {
         return;
     }
     state = CubeState.Stable;
     Planet.instance.Combine (type);
     GetComponent<Renderer>().material.color = colorNormal;
     GetComponent<Renderer>().enabled = false;
 }
예제 #2
0
 public Area(Vector3 center, Vector3 areaSize, Vector3 halfSize, ref CubeState[,,] mapState, MapGenerator map)
 {
     this.map = map;
     this.mapState = mapState;
     this.center = center;
     min = center - areaSize;
     max = center + areaSize;
     halfMin = map.PositionToIndex(center - halfSize);
     halfMin.y = 0;
     halfMax = map.PositionToIndex(center + halfSize);
     halfMax.y = mapState.GetLength(1);
 }
예제 #3
0
    public void AdjustHits(int amount)
    {
        hits = Mathf.Clamp (hits + amount, 0, maxHits);

        if(hits == 0)
        {
            state = CubeState.Depleted;
            //GetComponent<Renderer>().material.color = new Color(1,1,0,1f);
            Depleted();
        }
        else{
            state = CubeState.Harvesting;
            Planet.instance.Combine (type);
            GetComponent<Renderer>().enabled = true;
        }
    }
예제 #4
0
        public CubeState ResultState(CubeState state)
        {
            CubeState resultState = new CubeState(state);

            if (resultState.cubes[source] != -1)
            {
                resultState.towertops.Add(resultState.cubes[source]);                                 //the cube below the source is a new top if it exists
            }
            resultState.cubes[source] = target;
            if (target != -1)
            {
                resultState.towertops.Remove(target);
            }
            resultState.fromAction = this;
            return(resultState);
        }
예제 #5
0
    public void ReadState()
    {
        cubeState = FindObjectOfType <CubeState>();
        cubeMap   = FindObjectOfType <CubeMap>();

        // set the state of each position in the list of sides so we know
        // what color is in what position
        cubeState.up    = ReadFace(upRays, tUp);
        cubeState.down  = ReadFace(downRays, tDown);
        cubeState.left  = ReadFace(leftRays, tLeft);
        cubeState.right = ReadFace(rightRays, tRight);
        cubeState.front = ReadFace(frontRays, tFront);
        cubeState.back  = ReadFace(backRays, tBack);

        // update the map with the found positions
        cubeMap.Set();
    }
예제 #6
0
            private void VerifyAccelerationMap()
            {
                if (!Utils.ShouldVerify())
                {
                    return;
                }

                var actionCubeState = new CubeState();

                ActOps(actionCubeState);

                var mapCubeState = new CubeState();

                AccelerationMap.Act(mapCubeState);

                Utils.DebugAssert(mapCubeState.Equals(actionCubeState));
            }
예제 #7
0
            public CubeState(CubePuzzle cp) : base(cp)
            {
                _puzzle = cp;
                _image  = ArrayExtension.New <int>(6, _puzzle.Size, _puzzle.Size);

                for (var face = 0; face < _image.Length; face++)
                {
                    for (var j = 0; j < _puzzle.Size; j++)
                    {
                        for (var k = 0; k < _puzzle.Size; k++)
                        {
                            _image[face][j][k] = face;
                        }
                    }
                }
                _normalizedState = this;
            }
    public static void ApplyCubeState(Rigidbody rigidBody, NetworkInfo networkInfo, ref CubeState cubeState, ref Vector3 origin, bool smoothing = false)
    {
        if (networkInfo.IsHeldByPlayer())
        {
            networkInfo.DetachCubeFromPlayer();
        }

        if (cubeState.active)
        {
            if (rigidBody.IsSleeping())
            {
                rigidBody.WakeUp();
            }
        }

        if (!cubeState.active)
        {
            if (!rigidBody.IsSleeping())
            {
                rigidBody.Sleep();
            }
        }

        networkInfo.SetAuthorityIndex(cubeState.authorityIndex);
        networkInfo.SetAuthoritySequence(cubeState.authoritySequence);
        networkInfo.SetOwnershipSequence(cubeState.ownershipSequence);

        Vector3 position = new Vector3(cubeState.position_x, cubeState.position_y, cubeState.position_z) * 1.0f / Constants.UnitsPerMeter + origin;

        Quaternion rotation = SmallestThreeToQuaternion(cubeState.rotation_largest, cubeState.rotation_a, cubeState.rotation_b, cubeState.rotation_c);

        if (smoothing)
        {
            networkInfo.MoveWithSmoothing(position, rotation);
        }
        else
        {
            rigidBody.position = position;
            rigidBody.rotation = rotation;
        }

        rigidBody.velocity = new Vector3(cubeState.linear_velocity_x, cubeState.linear_velocity_y, cubeState.linear_velocity_z) * 1.0f / Constants.UnitsPerMeter;

        rigidBody.angularVelocity = new Vector3(cubeState.angular_velocity_x, cubeState.angular_velocity_y, cubeState.angular_velocity_z) * 1.0f / Constants.UnitsPerMeter;
    }
예제 #9
0
    void Update()
    {
        if (state != lastState)
        {
            if (state == CubeState.Pristine)
            {
                ren.material       = materials[stateIndex];
                rb.useGravity      = false;
                rb.velocity        = Vector3.zero;
                transform.position = new Vector3(transform.position.x, originalY, transform.position.z);
                ren.material       = materials[stateIndex];
                ptz.Stop();
            }
            else if (state == CubeState.Falling)
            {
                rb.useGravity = true;
                ptz.Play();
            }
            else
            {
                ren.material = materials[stateIndex];
            }

            lastState           = state;
            lastStateChangeTime = Time.time;
        }
        else
        {
            float stateChangeDelta = Time.time - lastStateChangeTime;

            if (state == CubeState.Cracked && stateChangeDelta > stateDelay + crackDelay)
            {
                state = CubeState.Fractured;
                audio.Play();
            }
            else if (state == CubeState.Fractured && stateChangeDelta > stateDelay)
            {
                state = CubeState.Falling;
            }
            else if (state == CubeState.Falling && stateChangeDelta > respawnDelay)
            {
                state = CubeState.Pristine;
            }
        }
    }
예제 #10
0
    public void ReadState()
    {
        cubeState = FindObjectOfType <CubeState>();
        cubeMap   = FindObjectOfType <CubeMap>();

        //readface는 6번 도니까 6번 타이핑할거임
        //여기 readCube 스크립트에서 바로 CubeState의 up을 업로드해줄거임
        cubeState.up = ReadFace(upRays, tUp);
        //tUp은 start하자마자 SetRayTransforms()함수에서 buildray()함수로 90도 돌려서 중앙을 바라보고있음
        cubeState.down  = ReadFace(downRays, tDown);
        cubeState.left  = ReadFace(leftRays, tLeft);
        cubeState.right = ReadFace(rightRays, tRight);
        cubeState.front = ReadFace(frontRays, tFront);
        cubeState.back  = ReadFace(backRays, tBack);

        // CubeState 구청에 모든 서류가 전달되었으므로 Set()함수씀
        cubeMap.Set(); //CubeState 구청자료를 cubeMap현장 ui패널에 대입
    }
예제 #11
0
    public void SetState(CubeState state)
    {
        switch (state)
        {
        case CubeState.Green:
            _currentState = GreenState;
            break;

        case CubeState.Yellow:
            _currentState = YellowState;
            break;

        case CubeState.Red:
            _currentState = RedState;
            break;
        }
        _currentState.EnterState();
    }
예제 #12
0
        public void Grow(int i = 3)
        {
            var g       = i * 2;
            var newCube = new CubeState[CubeSpace.GetLength(0) + g, CubeSpace.GetLength(1) + g, CubeSpace.GetLength(2) + g];

            for (var x = 0; x < CubeSpace.GetLength(0); x++)
            {
                for (var y = 0; y < CubeSpace.GetLength(1); y++)
                {
                    for (var z = 0; z < CubeSpace.GetLength(2); z++)
                    {
                        newCube[x + i, y + i, z + i] = CubeSpace[x, y, z];
                    }
                }
            }

            CubeSpace = newCube;
        }
예제 #13
0
    protected virtual void Awake()
    {
        m_OwnerNumber = EnumTypes.PlayerEnum.Unassigned;



        m_CubeSate       = CubeState.Grey;
        gameObject.layer = LayerMask.NameToLayer("Grey");
        m_IsFlippable    = true;

        if (m_Movable)
        {
            if (GetComponent <MovingCube>())
            {
                GetComponent <MovingCube>().enabled = true;
            }
        }
    }
예제 #14
0
 void HandleLocked()
 {
     if (hasFired && AudioSettings.dspTime >= timeToFire)
     {
         if (Destroyed())
         {
             state = CubeState.DESTROYED;
             material.SetColor("_Color", Color.red);
         }
         else
         {
             Color health = Color.Lerp(Color.red, Color.green, (float)currentHealth / (float)MaxHealth);
             material.SetColor("_Color", health);
             state    = CubeState.IDLE;
             hasHit   = false;
             hasFired = false;
         }
     }
 }
예제 #15
0
    public void SetMaterialColor(int _playerId)
    {
        if (!m_IsFlippable)
        {
            return;
        }


        Color col = Color.gray;

        if (_playerId == 0)
        {
            col = Color.black;
        }
        else if (_playerId == 1)
        {
            col = Color.white;
        }



        //m_Material.color = col;

        if (col == Color.black)
        {
            gameObject.layer = LayerMask.NameToLayer("Black");
            m_CubeSate       = CubeState.Black;
            SetFlip();
        }
        else if (col == Color.white)
        {
            gameObject.layer = LayerMask.NameToLayer("White");
            m_CubeSate       = CubeState.White;
            SetFlip();
        }
        else if (col == Color.gray)
        {
            gameObject.layer = LayerMask.NameToLayer("Grey");
            m_Visual.transform.eulerAngles = new Vector3(0, 90, 0);
            m_CubeSate = CubeState.Grey;
            SetFlip();
        }
    }
예제 #16
0
    // Start is called before the first frame update

    void Start()
    {
        controller    = new Controller();
        hitCountFaces = new Dictionary <string, int>();
        objectFaces   = new List <GameObject>();
        cubeState     = FindObjectOfType <CubeState>();
        hitCountFaces.Add("Up", 0);
        hitCountFaces.Add("Down", 0);
        hitCountFaces.Add("Left", 0);
        hitCountFaces.Add("Right", 0);
        hitCountFaces.Add("Front", 0);
        hitCountFaces.Add("Back", 0);

        fingers.Add(thumb);
        fingers.Add(index);
        fingers.Add(middle);
        fingers.Add(ring);
        fingers.Add(pinky);
    }
예제 #17
0
    public bool AddCube(ushort packetId, int cubeId, ref CubeState state)
    {
        int id = buffer.Get(packetId);

        if (id == -1)
        {
            return(false);
        }

        int priorityId = buffer.entries[id].count;

        Assert.IsTrue(priorityId < MaxCubes);
        buffer.entries[id].priorityIds[cubeId] = priorityId;
        buffer.entries[id].cubeIds[priorityId] = cubeId;
        buffer.entries[id].states[priorityId]  = state;
        buffer.entries[id].count++;

        return(true);
    }
예제 #18
0
            public void Act(CubeState cubeState)
            {
                bool      shouldVerify = Utils.ShouldVerify();
                CubeState opsCubeState = null;

                if (shouldVerify)
                {
                    opsCubeState = new CubeState(cubeState);
                    ActOps(opsCubeState);
                }

                if (RefMode)
                {
                    ActAccelerationMap(cubeState);
                    if (shouldVerify)
                    {
                        Utils.DebugAssert(opsCubeState.Equals(cubeState));
                    }
                }
                else
                {
                    if (Ops.Count == 0)
                    {
                        return;
                    }

                    if (Ops.Count >= OpCountForAccelerationMap)
                    {
                        ActAccelerationMap(cubeState);
                        if (shouldVerify)
                        {
                            Utils.DebugAssert(opsCubeState.Equals(cubeState));
                        }
                    }
                    else
                    {
                        // It's possible AccelerationMap != null. But we choose
                        // not to use it, because it would be slower.
                        ActOps(cubeState);
                    }
                }
            }
예제 #19
0
    public bool AddCubeState(ushort sequence, int cubeId, ref CubeState cubeState)
    {
        int index = sequenceBuffer.Find(sequence);

        if (index == -1)
        {
            return(false);
        }

        int numCubes = sequenceBuffer.Entries[index].numCubes;

        Assert.IsTrue(numCubes < Constants.NumCubes);

        sequenceBuffer.Entries[index].cubeLookup[cubeId]  = numCubes;
        sequenceBuffer.Entries[index].cubeIds[numCubes]   = cubeId;
        sequenceBuffer.Entries[index].cubeState[numCubes] = cubeState;
        sequenceBuffer.Entries[index].numCubes++;

        return(true);
    }
예제 #20
0
    private IEnumerator RotatingSection(List <Cubelet> children, Quaternion targetRot, float rotSpeed)
    {
        while (sectionRotator.RotationArrived(targetRot, rotSpeed))
        {
            yield return(null);
        }

        sectionRotator.transform.localRotation = targetRot;

        foreach (Cubelet c in children)
        {
            c.transform.SetParent(transform, true);
        }

        yield return(null);

        CheckCubeCompleted();

        currentState = CubeState.Idle;
    }
예제 #21
0
        }                                     //综合权重:F=G+H
        private void MyBtn_MouseClick(object sender, MouseEventArgs e)
        {
            int i = (int)thisCubeState;

            if (e.Button == MouseButtons.Left)
            {
                if (i < 3)
                {
                    i++;
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                if (i > 0)
                {
                    i--;
                }
            }
            thisCubeState = (CubeState)i;
            SetColor();
        }
예제 #22
0
    public void HitCube()
    {
        lockNum++;

        timeToLock = Metronome.Instance.GetFutureTime(Metronome.Instance.currentBar, Metronome.Instance.currentQuarter, Metronome.Instance.currentTick + 1);

        state = CubeState.LOCKED;
        if (lockNum == 0)
        {
            spriteRenderer.enabled = false;
        }
        else if (FullyLocked())
        {
            spriteRenderer.enabled = true;
            spriteRenderer.sprite  = lockSprites[7];
        }
        else
        {
            spriteRenderer.enabled = true;
            spriteRenderer.sprite  = lockSprites[lockNum - 1];
        }
    }
예제 #23
0
            public void SetPoint(int x, int y, int z, int w, CubeState cubeState)
            {
                var key = $"{x},{y},{z},{w}";

                if (_points.ContainsKey(key))
                {
                    _points[key] = cubeState;
                }
                else
                {
                    _points.Add(key, cubeState);
                }

                _minBounds.X = Math.Min(x, _minBounds.X);
                _minBounds.Y = Math.Min(y, _minBounds.Y);
                _minBounds.Z = Math.Min(z, _minBounds.Z);
                _minBounds.W = Math.Min(w, _minBounds.W);
                _maxBounds.X = Math.Max(x, _maxBounds.X);
                _maxBounds.Y = Math.Max(y, _maxBounds.Y);
                _maxBounds.Z = Math.Max(y, _maxBounds.Z);
                _maxBounds.W = Math.Max(w, _maxBounds.W);
            }
예제 #24
0
    // Update is called once per frame
    void Update()
    {
        if (isLocalPlayer)
        {
            KeyCode[] arrowKeys = { KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.RightArrow, KeyCode.LeftArrow };
            foreach (KeyCode arrowKey in arrowKeys)
            {
                if (!Input.GetKeyDown(arrowKey))
                {
                    continue;
                }

                pendingMoves.Enqueue(arrowKey);

                predictedState = Move(predictedState, arrowKey);

                CmdMoveOnServer(predictedState, arrowKey);
            }
        }

        SyncState();
    }
예제 #25
0
    internal void ChangeState(CubeState state)
    {
        switch (state)
        {
        case CubeState.normal:
            animator.SetTrigger("normal");
            break;

        case CubeState.obstacle:
            animator.SetTrigger("obstacle");
            break;

        case CubeState.start:
            animator.SetTrigger("start");
            break;

        case CubeState.end:
            animator.SetTrigger("end");
            break;
        }
        this.state = state;
    }
예제 #26
0
    private void SwitchState(CubeState state)
    {
        if (_cubeState == state)
        {
            return;
        }

        _cubeState = state;
        switch (_cubeState)
        {
        case CubeState.NONE:
            InitNoneState();
            break;

        case CubeState.TAP:
            InitTapState();
            break;

        case CubeState.BOOM:
            InitBoomState();
            break;
        }
    }
예제 #27
0
        public Cube(List <string> Data)
        {
            var width     = Data[0].Length;
            var cubeSpace = new CubeState[Data.Count, width, 1];

            for (int x = 0; x < Data.Count; x++)
            {
                for (int y = 0; y < width; y++)
                {
                    if (Data[x][y] == '#')
                    {
                        cubeSpace[x, y, 0] = CubeState.Active;
                    }

                    if (Data[x][y] == '.')
                    {
                        cubeSpace[x, y, 0] = CubeState.Inactive;
                    }
                }
            }

            CubeSpace = cubeSpace;
        }
예제 #28
0
    // Use this for initialization
    void Start()
    {
        //Get the renderer of the object so we can access the color
        rend = GetComponent <Renderer>();
        //Set the initial color (0f,0f,0f,0f)
        //Debug.Log(gameController.boardStates.GetItem(cubeNumber - 1).cubeNumber);
        //Debug.Log(gameController.boardStates.GetItem(cubeNumber - 1).state);

        getState();
        if (cubeNumber == 1 || cubeNumber == 25)
        {
            state = CubeState.CubeNormal;
            rend.material.color = Color.black;
            if (cubeNumber == 25)
            {
                Vector3 newPos = new Vector3(this.transform.position.x + 0.6f, this.transform.position.y + 0.5f, this.transform.position.z - 0.4f);
                Instantiate(house, newPos, Quaternion.Euler(new Vector3(0.0f, 90.0f, 0.0f)));
            }
        }
        else if (state == CubeState.CubeNormal)
        {
            rend.material.color = Color.green;
        }
        else if (state == CubeState.CubeHelp)
        {
            rend.material.color = Color.white;
            Vector3 newPos = new Vector3(this.transform.position.x, this.transform.position.y + 0.5f, this.transform.position.z);
            Instantiate(rocketShoe, newPos, Quaternion.identity);
        }
        else if (state == CubeState.CubeDanger)
        {
            rend.material.color = Color.red;
            Vector3 newPos = new Vector3(this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z);
            Instantiate(rod, newPos, Quaternion.identity);
        }
    }
            private List <BlockSet> StablizerChain_FixedStep(int stepLength)
            {
                var ret   = new List <BlockSet>();
                var state = new CubeState();

                var solvingOrder = Enumerable.Range(0, state.Blocks.Length)
                                   .OrderBy(i => i, new CubeBlockIndexComparator(state))
                                   .ToList();

                var  iterator    = solvingOrder.GetEnumerator();
                bool moveForward = true;

                while (moveForward)
                {
                    var blockSet = new BlockSet(state);
                    for (int i = 0; i < stepLength; i++)
                    {
                        if (iterator.MoveNext())
                        {
                            blockSet.Indexes.Add(iterator.Current);
                        }
                        else
                        {
                            moveForward = false;
                            break;
                        }
                    }

                    if (blockSet.Indexes.Count > 0)
                    {
                        ret.Add(blockSet);
                    }
                }

                return(ret);
            }
예제 #30
0
    /// <summary>
    /// 状態の変化によって、マテリアルを変更する
    /// </summary>
    /// <param name="_state">今のステートを引数として渡す。</param>
    private void change_material(CubeState _state)
    {
        switch (_state)
        {
        case CubeState.Normal:
            // my_material = mat_normal;
            mesh_renderer.material = mat_normal;
            break;

        case CubeState.Select:
            //my_material = mat_select;
            mesh_renderer.material = mat_select;
            break;

        case CubeState.Confilm:
            //my_material = mat_confilm;
            mesh_renderer.material = mat_select;
            break;

        case CubeState.Goal:
            mesh_renderer.material = mat_goal;
            break;
        }
    }
예제 #31
0
 void CmdMoveOnServer(KeyCode arrowKey)
 {
     state = Move(state, arrowKey);
 }
예제 #32
0
    static void test_delta_buffer()
    {
#if !DEBUG_AUTHORITY
        Log("test_delta_buffer");
        const int    NumCubeStates   = 5;
        const int    DeltaBufferSize = 256;
        const ushort Sequence        = 100; //check that querying for a sequence number not in the buffer returns false
        const ushort ResetSequence   = 1000;
        var          buffer          = new DeltaBuffer(DeltaBufferSize);
        var          state           = CubeState.defaults;
        var          result          = buffer.GetPacketCube(Sequence, ResetSequence, 0, ref state);

        IsTrue(result == false);
        result = buffer.AddPacket(Sequence, ResetSequence); //now add an entry for the sequence number
        IsTrue(result);

        var cubeIds    = new int[NumCubeStates]; //add a few cube states for the packet
        var cubeStates = new CubeState[NumCubeStates];

        for (int i = 0; i < NumCubeStates; ++i)
        {
            cubeStates[i]           = CubeState.defaults;
            cubeStates[i].positionX = i;
            int cubeId = 10 + i * 10;
            cubeIds[i] = cubeId;
            result     = buffer.AddCube(Sequence, cubeId, ref cubeStates[i]);
            IsTrue(result);
        }

        for (int i = 0; i < NumCubeStates; ++i) //verify that we can find the cube state we added by cube id and sequence
        {
            int cubeId = 10 + i * 10;
            result = buffer.GetPacketCube(Sequence, ResetSequence, cubeId, ref state);
            IsTrue(result);
            IsTrue(state.positionX == cubeStates[i].positionX);
        }

        for (int i = 0; i < Constants.MaxCubes; ++i) //verify that get cube state returns false for cube ids that weren't in this packet
        {
            var validCubeId = false;

            for (int j = 0; j < NumCubeStates; ++j)
            {
                if (cubeIds[j] == i)
                {
                    validCubeId = true;
                }
            }

            if (validCubeId)
            {
                continue;
            }

            result = buffer.GetPacketCube(Sequence, ResetSequence, i, ref state);
            IsTrue(result == false);
        }

        int         packetNumCubes; //grab the packet data for the sequence and make sure it matches what we expect
        int[]       packetCubeIds;
        CubeState[] packetCubeState;
        result = buffer.GetPacketCubes(Sequence, ResetSequence, out packetNumCubes, out packetCubeIds, out packetCubeState);
        IsTrue(result == true);
        IsTrue(packetNumCubes == NumCubeStates);

        for (int i = 0; i < NumCubeStates; ++i)
        {
            IsTrue(packetCubeIds[i] == 10 + i * 10);
            IsTrue(packetCubeState[i].positionX == cubeStates[i].positionX);
        }

        result = buffer.GetPacketCubes(Sequence + 1, ResetSequence, out packetNumCubes, out packetCubeIds, out packetCubeState); //try to grab packet data for an invalid sequence number and make sure it returns false
        IsTrue(result == false);

        result = buffer.GetPacketCubes(Sequence, ResetSequence + 1, out packetNumCubes, out packetCubeIds, out packetCubeState); //try to grab packet data for a different reset sequence number and make sure it returns false
        IsTrue(result == false);
#endif // #if !DEBUG_AUTHORITY
    }
예제 #33
0
 public void Explode()
 {
     t = 0;
     state = CubeState.Exploded;
     //isActive = false;
     //isExplode = true;
     Planet.instance.Combine (type);
     DestroyImmediate(GetComponent<Collider>());
     GetComponent<Renderer>().enabled = true;
 }
예제 #34
0
 void CmdRotateOnServer(KeyCode rotkey)
 {
     state = Rotate(state, rotkey);
 }
예제 #35
0
 public void SetHover()
 {
     if(state != CubeState.Stable)
     {
         return;
     }
     state = CubeState.Selected;
     Planet.instance.Combine (type);
     GetComponent<Renderer>().enabled = true;
     GetComponent<Renderer>().material.color = colorNormal * 2;
     // most colorNormals have a 0.5f value, so this makes it brighter.
 }