예제 #1
0
    IEnumerator HitCoroutine()
    {
        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hitInfo, currentHand.range))
        {
            var individualCube = hitInfo.transform.GetComponent <IndividualCube>();
            var adjacencyGraph = hitInfo.transform.root.GetComponent <CreateAdjacencyGraph>();

            if (hitInfo.transform.tag == "WeakPoint")
            {
                individualCube.DestroyParent();
            }

            if (hitInfo.transform.tag == "Enemy")
            {
                //Have fun~ (  ̄ 3 ̄)y▂ξ

                IndividualCube weakPoint = null;
                weakPoint = adjacencyGraph.GetWeakPoint();

                hitInfo.transform.GetComponent <IndividualCube>().MarkAsHit(2);
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyHit();

                weakPoint.GetComponent <IndividualCube>().CheckDetached();
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyDetached();
            }
        }

        yield return(null);
    }
예제 #2
0
    void CreateDictionary(Transform curr)
    {
        if (curr.childCount == 0)
        {
            return;
        }

        for (int i = 0; i < curr.childCount; i++)
        {
            var individualCube = curr.GetChild(i).GetComponent <IndividualCube>();

            //-----------Recursion
            if (curr.GetChild(i).childCount > 0)
            {
                Transform newCurr = curr.GetChild(i);
                CreateDictionary(newCurr);
            }

            //---------Turn its name into a Vecter3
            if (individualCube != null)
            {
                string   name   = curr.GetChild(i).name;
                string[] result = name.Split(new char[] { '_' });
                int      x      = int.Parse(result[result.Length - 3]);
                int      y      = int.Parse(result[result.Length - 2]);
                int      z      = int.Parse(result[result.Length - 1]);

                individualCube.voxelLocalPosition = new Vector3(x, y, z);
                Vector3        key   = individualCube.voxelLocalPosition;
                IndividualCube child = individualCube;

                Children.Add(key, child);
            }
        }
    }
예제 #3
0
 void InitAllCubes()
 {
     allCubes.AddRange(GetComponentsInChildren <IndividualCube>());
     if (useWeakpoint)
     {
         weakPoint = allCubes[Random.Range(0, allCubes.Count)];
     }
 }
예제 #4
0
 private void Start()
 {
     cam = Entity_Tracker.Instance.PlayerEntity.GetComponentInChildren <Camera>();
     if (TryGetComponent <IndividualCube>(out IndividualCube cube))
     {
         individualCube = cube;
     }
     col = GetComponent <Collider>();
 }
예제 #5
0
    public void WeakPointFreeWalking()
    {
        IndividualCube destination = null;

        switch (direction)
        {
        case 1:
            destination = weakPoint.frontCube;
            break;

        case 2:
            destination = weakPoint.backCube;
            break;

        case 3:
            destination = weakPoint.leftCube;
            break;

        case 4:
            destination = weakPoint.rightCube;
            break;

        case 5:
            destination = weakPoint.topCube;
            break;

        case 6:
            destination = weakPoint.bottomCube;
            break;
        }

        weakPoint.transform.GetChild(0).GetComponent <Renderer>().material = white;
        weakPoint.gameObject.tag = "Enemy";
        weakPoint.UnsetNeighboursToWeakPoint(2, white);

        if (distance > 0 && destination != null)
        {
            weakPoint = destination;

            distance--;
        }
        else
        {
            distance = Random.Range(3, 8);
            List <int>            neighbourIndex = weakPoint.GetNeighbourIndices();
            List <IndividualCube> neighbours     = weakPoint.GetNeighbours();
            int randIndex = Random.Range(0, neighbours.Count);
            weakPoint = neighbours[randIndex];
            direction = neighbourIndex[randIndex];
        }

        weakPoint.transform.GetChild(0).GetComponent <Renderer>().material = red;
        weakPoint.gameObject.tag = "WeakPoint";
        weakPoint.SetNeighboursToWeakPoint(2, red);
    }
예제 #6
0
    void Shooting()
    {
        RaycastHit   hitInfo;
        LineRenderer line = gameObject.AddComponent <LineRenderer>();

        if (line != null)
        {
            line.positionCount = 2;
            line.startWidth    = 0.02f;
            line.endWidth      = 0.02f;
        }

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hitInfo, maxDistance))
        {
            if (hitInfo.transform.CompareTag("WeakPoint"))
            {
                if (line != null)
                {
                    line.SetPositions(new Vector3[2] {
                        cam.transform.position + cam.transform.right * 0.2f, hitInfo.point
                    });
                }
                hitInfo.transform.GetComponent <IndividualCube>().DestroyParent();
            }

            if (hitInfo.transform.CompareTag("Enemy"))
            {
                if (line != null)
                {
                    line.SetPositions(new Vector3[2] {
                        cam.transform.position + cam.transform.right * 0.2f, hitInfo.point
                    });
                }
                //Have fun~ (  ̄ 3 ̄)y▂ξ

                IndividualCube weakPoint = null;
                weakPoint = hitInfo.transform.root.GetComponent <CreateAdjacencyGraph>().GetWeakPoint();

                hitInfo.transform.GetComponent <IndividualCube>().MarkAsHit(2);
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyHit();

                weakPoint.GetComponent <IndividualCube>().CheckDetached();
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyDetached();
            }
        }
        if (line != null)
        {
            line.SetPositions(new Vector3[2] {
                cam.transform.position + cam.transform.right * 0.2f, cam.transform.forward * maxDistance
            });
        }
        Destroy(line, 0.2f);
    }