Esempio n. 1
0
    void LookForTargetDown()
    {
        var hitNPCdown    = Physics2D.Raycast((Center.position - transform.up * 0.225f), Vector2.down, distance, visibleObjects);
        var hitPlayerdown = Physics2D.Raycast((Center.position - transform.up * 0.225f), Vector2.down, distance, layerMaskPlayer);

        if (hitPlayerdown && (hitPlayerdown.transform.tag == "Player1"))
        {
            linerenderer.SetPosition(1, new Vector3(0, -hitPlayerdown.distance, 0));

            x = Random.Range(0, 19);
            Instantiate(deathAnimPlayers, hitPlayerdown.transform.position, Quaternion.identity);
            hitPlayerdown.transform.parent.gameObject.transform.position = GameObject.Find("NPC" + x).transform.position;
            Destroy(GameObject.Find("NPC" + x));
            PointSystem.AddScoreP1(innocentKillPoint);
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitPlayerdown && (hitPlayerdown.transform.tag == "Player3"))
        {
            linerenderer.SetPosition(1, new Vector3(0, -hitPlayerdown.distance, 0));

            x = Random.Range(0, 19);
            Instantiate(deathAnimPlayers, hitPlayerdown.transform.position, Quaternion.identity);
            hitPlayerdown.transform.parent.gameObject.transform.position = GameObject.Find("NPC" + x).transform.position;
            Destroy(GameObject.Find("NPC" + x));
            PointSystem.AddScoreP3(innocentKillPoint);
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitPlayerdown && (hitPlayerdown.transform.tag == "Player4"))
        {
            linerenderer.SetPosition(1, new Vector3(0, -hitPlayerdown.distance, 0));

            x = Random.Range(0, 19);
            Instantiate(deathAnimPlayers, hitPlayerdown.transform.position, Quaternion.identity);
            hitPlayerdown.transform.parent.gameObject.transform.position = GameObject.Find("NPC" + x).transform.position;
            Destroy(GameObject.Find("NPC" + x));
            PointSystem.AddScoreP4(innocentKillPoint);
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitNPCdown && (hitNPCdown.transform.tag == "NPC"))
        {
            linerenderer.SetPosition(1, new Vector3(0, -hitNPCdown.distance, 0));

            Instantiate(deathAnimPlayers, hitNPCdown.transform.position, Quaternion.identity);
            Destroy(hitNPCdown.transform.gameObject);
            PointSystem.AddScoreP2(innocentKillPoint);
        }

        if (hitNPCdown && (hitNPCdown.transform.tag == "Target"))
        {
            linerenderer.SetPosition(1, new Vector3(0, -hitNPCdown.distance, 0));

            Instantiate(deathAnimTarget, hitNPCdown.transform.position, Quaternion.identity);
            hitNPCdown.transform.position = GameObject.Find("Respawn").transform.position;
            NPC_Spawner.timerActive();
            PointSystem.AddScoreP2(playerKillPoint);
        }
        if (hitNPCdown && (hitNPCdown.transform.tag == "Wall"))
        {
            Debug.Log("Hit the Wall");
            linerenderer.SetPosition(1, new Vector3(0, -distance, 0));
        }
    }
Esempio n. 2
0
    void LookForTargetRight()
    {
        var hitNPCright    = Physics2D.Raycast((Center.position + transform.right * 0.225f), Vector2.right, distance, visibleObjects);
        var hitPlayerright = Physics2D.Raycast((Center.position + transform.right * 0.225f), Vector2.right, distance, layerMaskPlayer);

        linerenderer.SetPosition(0, Vector3.zero);        //sets line position to where the object is.

        if (hitPlayerright && (hitPlayerright.transform.tag == "Player1"))
        {
            linerenderer.SetPosition(1, new Vector3(hitPlayerright.distance, 0, 0));

            x = Random.Range(0, 19);
            Instantiate(deathAnimPlayers, hitPlayerright.transform.position, Quaternion.identity);
            hitPlayerright.transform.parent.gameObject.transform.position = GameObject.Find("NPC" + x).transform.position;
            Destroy(GameObject.Find("NPC" + x));
            PointSystem.AddScoreP1(innocentKillPoint);
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitPlayerright && (hitPlayerright.transform.tag == "Player3"))
        {
            linerenderer.SetPosition(1, new Vector3(hitPlayerright.distance, 0, 0));

            x = Random.Range(0, 19);
            Instantiate(deathAnimPlayers, hitPlayerright.transform.position, Quaternion.identity);
            hitPlayerright.transform.parent.gameObject.transform.position = GameObject.Find("NPC" + x).transform.position;
            Destroy(GameObject.Find("NPC" + x));
            PointSystem.AddScoreP3(innocentKillPoint);
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitPlayerright && (hitPlayerright.transform.tag == "Player4"))
        {
            linerenderer.SetPosition(1, new Vector3(hitPlayerright.distance, 0, 0));

            x = Random.Range(0, 19);
            Instantiate(deathAnimPlayers, hitPlayerright.transform.position, Quaternion.identity);
            hitPlayerright.transform.parent.gameObject.transform.position = GameObject.Find("NPC" + x).transform.position;
            Destroy(GameObject.Find("NPC" + x));
            PointSystem.AddScoreP4(innocentKillPoint);
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitNPCright && (hitNPCright.transform.tag == "NPC"))
        {
            linerenderer.SetPosition(1, new Vector3(hitNPCright.distance, 0, 0));

            Instantiate(deathAnimPlayers, hitNPCright.transform.position, Quaternion.identity);
            Destroy(hitNPCright.transform.gameObject);
            PointSystem.AddScoreP2(innocentKillPoint);
        }

        if (hitNPCright && (hitNPCright.transform.tag == "Target"))
        {
            linerenderer.SetPosition(1, new Vector3(hitNPCright.distance, 0, 0));

            Instantiate(deathAnimTarget, hitNPCright.transform.position, Quaternion.identity);
            hitNPCright.transform.position = GameObject.Find("Respawn").transform.position;
            NPC_Spawner.timerActive();
            PointSystem.AddScoreP2(playerKillPoint);
        }

        if (hitNPCright && (hitNPCright.transform.tag == "Wall"))
        {
            Debug.Log("Hit the Wall");
            linerenderer.SetPosition(1, new Vector3(distance, 0, 0));
        }
    }