Example #1
0
    public void Dig(IntVect targetLocation, Vector3 hitPoint)
    {
        DateTime currentDigTime = DateTime.Now;

        if (targetLocation != m_DiggingLocation)
        {
            m_DiggingAmount   = 100;
            m_DiggingLocation = targetLocation;
            m_LastDigTime     = currentDigTime;
            Diggings.Enqueue(hitPoint);
        }
        else
        {
            if (currentDigTime - m_LastDigTime > m_DigDuration)
            {
                Diggings.Enqueue(hitPoint);
                m_DiggingAmount = m_DiggingAmount - 25;
                m_LastDigTime   = currentDigTime;

                if (m_DiggingAmount <= 0)
                {
                    RemoveBlockAt(targetLocation);
                    m_DiggingAmount = 100;
                }
            }
        }
    }
Example #2
0
 public void RemoveBlockAt(IntVect hitPoint)
 {
     m_WorldData.SetBlockTypeWithRegeneration(hitPoint.X, hitPoint.Y, hitPoint.Z, BlockType.Air);
     m_LightProcessor.RecalculateLightingAround(hitPoint.X, hitPoint.Y, hitPoint.Z);
     RegenerateChunks(hitPoint.X / m_WorldData.ChunkBlockHeight,
                      hitPoint.Y / m_WorldData.ChunkBlockHeight,
                      hitPoint.Z / m_WorldData.ChunkBlockDepth);
 }
Example #3
0
    public void FireNukeAt(IntVect hitPoint, Ray ray)
    {
        Debug.Log(hitPoint + " - " + ray);
        float xInc = hitPoint.X;
        float yInc = hitPoint.Y;
        float zInc = hitPoint.Z;

        for (int distance = 0; distance <= 10; distance++)
        {
            xInc += ray.direction.x;
            yInc += ray.direction.y;
            zInc += ray.direction.z;
            for (int numBlocks = 0; numBlocks < 10; numBlocks++)
            {
                int blockX = (int)(UnityEngine.Random.insideUnitSphere.x * 3 + xInc);
                int blockY = (int)(UnityEngine.Random.insideUnitSphere.y * 3 + yInc);
                int blockZ = (int)(UnityEngine.Random.insideUnitSphere.z * 3 + zInc);
                m_WorldData.SetBlockTypeWithRegeneration(blockX, blockY, blockZ, BlockType.Air);
            }
        }
    }
    private void ProcessPlayerInput()
    {
        if (!Input.anyKey)
        {
            return;
        }



        m_ProcessAllChunksAtOnce = true;



        if (Input.inputString.Contains("t"))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f, 0));
            if (Physics.Raycast(ray, out hit, 4.0f))
            {
                WorldData.SetBlockLightWithRegeneration((int)hit.point.x, (int)hit.point.z, (int)hit.point.y, 255);
                m_World.RegenerateChunks();
            }
        }

        if (Input.GetKey(KeyCode.Mouse0))
        {
            //m_World.RemoveBlockAt(blockHitPoint);
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f, 0));
            if (Physics.Raycast(ray, out hit, 4.0f))
            {
                Vector3 hitPoint      = hit.point + (ray.direction.normalized * 0.01f);
                IntVect blockHitPoint = new IntVect((int)hitPoint.x, (int)hitPoint.z, (int)hitPoint.y);
                m_World.Dig(blockHitPoint, hitPoint);
            }
        }
    }
Example #5
0
    public override bool Equals(object obj)
    {
        IntVect other = (IntVect)obj;

        return(other.X == m_X && other.Y == m_Y && other.Z == m_Z);
    }