コード例 #1
0
    public override void TestTile(bool isTNT = false)
    {
        Ray        ray = new Ray(transform.position, Vector3.down);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 1f))
        {
            if (hit.transform.gameObject.GetComponent <CubeDash>())
            {
                CubeDash tmpCube = hit.transform.gameObject.GetComponent <CubeDash>();

                if ((int)tmpCube.dashOrientation == 0)
                {
                    orientation = Vector3.forward;
                }
                else if ((int)tmpCube.dashOrientation == 1)
                {
                    orientation = Vector3.back;
                }
                else if ((int)tmpCube.dashOrientation == 2)
                {
                    orientation = Vector3.right;
                }
                else
                {
                    orientation = Vector3.left;
                }

                SetModeDash();
            }
            else if (hit.transform.gameObject.GetComponent <CubeDetonator>())
            {
                CubeDetonator tmpCube = hit.transform.gameObject.GetComponent <CubeDetonator>();

                tmpCube.ActivateTnt();
            }
            else if (hit.transform.gameObject.GetComponent <CubeTeleporter>())
            {
                CubeTeleporter tmpCube = hit.transform.gameObject.GetComponent <CubeTeleporter>();

                tmpCube.TeleportPlayer(this);
            }
            else if (hit.transform.gameObject.GetComponent <CubeSlid>())
            {
                if (orientation != Vector3.zero)
                {
                    if (!TestWall())
                    {
                        SetModeSlid();
                    }
                }
            }
        }
        else
        {
            DoAction = DoActionFall;
        }
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: Nogous/AgenceIIM
    public override void TestTile(bool isTNT = false)
    {
        Ray        ray = new Ray(transform.position, Vector3.down);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 1f))
        {
            if (faceColor[1].GetComponent <Renderer>().material.color == baseColor && !hit.transform.gameObject.GetComponent <CubePaint>())
            {
                Smoke.Play();
            }

            if (hit.transform.gameObject.GetComponent <CubePaint>())
            {
                CubePaint tmpCube = hit.transform.gameObject.GetComponent <CubePaint>();

                Color tmpColor = faceColor[1].GetComponent <Renderer>().material.color;

                if (tmpCube.colorPotencial > 0)
                {
                    if (tmpColor != baseColor)
                    {
                        if (faceColor[1].GetComponent <Renderer>().material.color != tmpCube.GetPaintColor())
                        {
                            SetModeVoid();
                            StartCoroutine(Death());
                            Explode();
                            return;
                        }
                    }
                    else
                    {
                        faceColor[1].GetComponent <Renderer>().material.color = tmpCube.GetPaintColor();
                        //reduce Color

                        /*tmpCube.colorPotencial -= 25;
                         * tmpCube.GetComponent<Renderer>().material.color = Color.Lerp(tmpCube.GetComponent<Renderer>().material.color, Color.white, 1 - (float)tmpCube.colorPotencial / 100);*/
                        //Hide Color

                        tmpCube.colorPotencial           -= tmpCube.colorLost;
                        tmpCube.mask.transform.localScale = Vector3.Lerp(tmpCube.initalScale, Vector3.zero, 1 - (float)tmpCube.colorPotencial / 100);
                    }
                }
                if (!isTNT)
                {
                    nbMove++;
                }
                SetModeWait();
            }
            else if (hit.transform.gameObject.GetComponent <CubeCleaner>())
            {
                CubeCleaner tmpCleaner = hit.transform.gameObject.GetComponent <CubeCleaner>();
                tmpCleaner.Clean(this);

                if (!isTNT)
                {
                    nbMove++;
                }

                SetModeWait();
            }
            else if (hit.transform.gameObject.GetComponent <CubeDash>())
            {
                CubeDash tmpCube = hit.transform.gameObject.GetComponent <CubeDash>();
                AudioManager.instance.Play("Bloc Glissant");
                if ((int)tmpCube.dashOrientation == 0)
                {
                    orientation = Vector3.forward;
                    moveDir     = MoveDir.up;
                }
                else if ((int)tmpCube.dashOrientation == 1)
                {
                    orientation = Vector3.back;
                    moveDir     = MoveDir.down;
                }
                else if ((int)tmpCube.dashOrientation == 2)
                {
                    orientation = Vector3.right;
                    moveDir     = MoveDir.right;
                }
                else
                {
                    orientation = Vector3.left;
                    moveDir     = MoveDir.left;
                }

                SetModeDash();
            }
            else if (hit.transform.gameObject.GetComponent <CubeDetonator>())
            {
                CubeDetonator tmpDetonator = hit.transform.gameObject.GetComponent <CubeDetonator>();
                tmpDetonator.ActivateTnt();

                SetModeWait();
                if (!isTNT)
                {
                    nbMove++;
                }
            }
            else if (hit.transform.gameObject.GetComponent <CubeTeleporter>())
            {
                CubeTeleporter tmpTeleporter = hit.transform.gameObject.GetComponent <CubeTeleporter>();
                tmpTeleporter.TeleportPlayer(this);

                SetModeWait();
                if (!isTNT)
                {
                    nbMove++;
                }
            }
            else if (hit.transform.gameObject.GetComponent <CubeSlid>())
            {
                if (!TestWall())
                {
                    SetModeSlid();
                }
                else
                {
                    SetModeWait();
                    if (!isTNT)
                    {
                        nbMove++;
                    }
                }
            }
            else
            {
                SetModeWait();
                if (!isTNT)
                {
                    nbMove++;
                }
            }
        }
        else
        {
            DoAction = DoActionFall;

            StartCoroutine(Death("fall"));
        }

        // test tile d'arriver
        GameManager.instance.txtNbCoups.text = "Coups : " + nbMove;
    }