void Update()
    {
        if (fail == true)
        {
            Piece1.GetComponent <SpriteRenderer>().sprite = CrumbleWall;
            Piece2.GetComponent <SpriteRenderer>().sprite = CrumbleWall;
            Piece3.GetComponent <SpriteRenderer>().sprite = CrumbleWall;
            Piece4.GetComponent <SpriteRenderer>().sprite = CrumbleWall;
            Win = 0;
        }

        else if (p1 == true && p2 == true && p3 == true && p4 == true)
        {
            Piece1.GetComponent <SpriteRenderer>().sprite = FixWall;
            Piece2.GetComponent <SpriteRenderer>().sprite = FixWall;
            Piece3.GetComponent <SpriteRenderer>().sprite = FixWall;
            Piece4.GetComponent <SpriteRenderer>().sprite = FixWall;
            Win = 1;
        }

        else
        {
            if (p1 == true)
            {
                Piece1.GetComponent <SpriteRenderer>().sprite = FixWall;
            }
            if (p2 == true)
            {
                Piece2.GetComponent <SpriteRenderer>().sprite = FixWall;
            }
            if (p3 == true)
            {
                Piece3.GetComponent <SpriteRenderer>().sprite = FixWall;
            }
            if (p4 == true)
            {
                Piece4.GetComponent <SpriteRenderer>().sprite = FixWall;
            }
            p1   = Piece1.GetComponent <ClickItem>().Clicked;
            p2   = Piece2.GetComponent <ClickItem>().Clicked;
            p3   = Piece3.GetComponent <ClickItem>().Clicked;
            p4   = Piece4.GetComponent <ClickItem>().Clicked;
            fail = Back.GetComponent <ClickItem>().Clicked;
        }

        if (T < 0)
        {
            PlayerPrefs.SetInt("Result", Win);
            Back.GetComponent <PresentResults>().enabled = true;
            Back.GetComponent <GameWall>().enabled       = false;
        }
        else
        {
            T = T - Time.deltaTime;
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        //gameObject.GetComponentInParent<HingeJoint>();
        Camera cam = SelectCam.GetComponent <Camera>();

        Vector3    mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
        Collider2D col      = Physics2D.OverlapPoint(mousePos);

        if (Input.GetMouseButtonDown(0))
        {
            //右に移動
            foreach (GameObject Right in right)
            {
                if (col == Right.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(this.transform.position.x + 40, this.transform.position.y, -10);
                }
            }
            //左に移動
            foreach (GameObject Left in left)
            {
                if (col == Left.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(this.transform.position.x - 40, this.transform.position.y, -10);
                }
            }
            //上に移動
            foreach (GameObject UP in up)
            {
                if (col == UP.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(0, 0, -10);
                }
            }
            //下に移動
            foreach (GameObject Down in down)
            {
                if (col == Down.GetComponent <GameObject>())
                {
                    SelectCam.transform.position = new Vector3(0, -20, -10);
                }
            }
            //タイトルへ戻る
            foreach (GameObject Back in back)
            {
                if (col == Back.GetComponent <GameObject>())
                {
                    Application.LoadLevel("0");
                    //Scene0 = Title.name
                }
            }
        }
    }
 void Start()
 {
     ScoreText.enabled = false;
     LivesText.enabled = false;
     RuleText.enabled  = false;
     Progress          = 1;
     Win  = 0;
     T    = PlayerPrefs.GetFloat("PTime");
     tt   = T;
     p1   = Piece1.GetComponent <ClickItem>().Clicked;
     p2   = Piece2.GetComponent <ClickItem>().Clicked;
     p3   = Piece3.GetComponent <ClickItem>().Clicked;
     p4   = Piece4.GetComponent <ClickItem>().Clicked;
     fail = Back.GetComponent <ClickItem>().Clicked;
 }
    public void Setup(Rigidbody2D rb2d, Cell cell)
    {
        foreach (Flagellum flagellum in cell.cellProperties.flagellums)
        {
            switch (flagellum.position)
            {
            case Flagellum.Position.Front:
                Front.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Front.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Front.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Front_Right:
                Front_Right.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Front_Right.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Front_Right.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Right:
                Right.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Right.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Right.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Back_Right:
                Back_Right.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Back_Right.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Back_Right.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Back:
                Back.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Back.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Back.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Back_Left:
                Back_Left.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Back_Left.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Back_Left.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Left:
                Left.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Left.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Left.SetActive(flagellum.impulseFrequency > 0);
                break;

            case Flagellum.Position.Front_Left:
                Front_Left.transform.localScale = new Vector3(Front.transform.localScale.x, flagellum.size, Front.transform.localScale.z);
                Front_Left.GetComponent <FlagellumImpulseFrequency>().value = flagellum.impulseFrequency;
                Front_Left.SetActive(flagellum.impulseFrequency > 0);
                break;
            }
        }

        this.rb2d = rb2d;
        this.degreeToObjective = UnityEngine.Random.Range(0, 360);
        this.cell = cell;

        if (!Application.isPlaying)
        {
            return;
        }

        StartCoroutine(DoFlagellumPropulsion(Front));
        StartCoroutine(DoFlagellumPropulsion(Front_Right));
        StartCoroutine(DoFlagellumPropulsion(Right));
        StartCoroutine(DoFlagellumPropulsion(Back_Right));
        StartCoroutine(DoFlagellumPropulsion(Back));
        StartCoroutine(DoFlagellumPropulsion(Back_Left));
        StartCoroutine(DoFlagellumPropulsion(Left));
        StartCoroutine(DoFlagellumPropulsion(Front_Left));
    }
Exemple #5
0
 // Each time you press a button move to the correct menu page
 void FixedUpdate()
 {
     // Called when you quit a game you're in
     if (Store.activeSelf && !_stop)
     {
         Lights.GetComponent <ParticleController>().Play();
         _stop = true;
     }
     // Called after log in
     if (!_started && GetComponent <Controller>().LoggedIn)
     {
         _started = true;
         Store.SetActive(true);
         Single.SetActive(true);
         Title.SetActive(true);
         Online.SetActive(true);
         Controls.SetActive(true);
     }
     // Called when you enter the store
     if (Store.GetComponent <ButtonController>().Pressed == true)
     {
         Store.transform.GetComponent <Renderer>().material = Materials[0];
         Store.GetComponent <ButtonController>().Pressed    = false;
         Store.SetActive(false);
         Single.SetActive(false);
         Title.SetActive(false);
         Online.SetActive(false);
         Controls.SetActive(false);
         Shop.SetActive(true);
         BackTL.SetActive(true);
         Transition(2);
     }
     // Called when you select the online button
     if (Online.GetComponent <ButtonController>().Pressed == true)
     {
         Online.transform.GetComponent <Renderer>().material = Materials[0];
         Host.transform.GetComponent <Renderer>().material   = Materials[0];
         Online.GetComponent <ButtonController>().Pressed    = false;
         Host.SetActive(true);
         Join.SetActive(true);
         Back.SetActive(true);
         Store.SetActive(false);
         Title.SetActive(false);
         Single.SetActive(false);
         Online.SetActive(false);
         Controls.SetActive(false);
         Transition(2);
     }
     // Called when you select the back button
     if (Back.GetComponent <ButtonController>().Pressed == true)
     {
         Back.transform.GetComponent <Renderer>().material = Materials[0];
         Back.GetComponent <ButtonController>().Pressed    = false;
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         Store.SetActive(true);
         Single.SetActive(true);
         Title.SetActive(true);
         Online.SetActive(true);
         Controls.SetActive(true);
         Transition(1);
     }
     // Called when you request to be a host
     if (Host.GetComponent <ButtonController>().Pressed == true)
     {
         Host.transform.GetComponent <Renderer>().material = Materials[0];
         Lights.GetComponent <ParticleController>().Stop();
         Host.GetComponent <ButtonController>().Pressed = false;
         // Respawns the networkcontroller on the server so you can pass messages to clients
         _networkManager.GetComponent <NetworkManager>().StartHost();
         NetworkServer.Spawn(NetworkController);
         foreach (GameObject g in GameModes)
         {
             GameObject mode = GameObject.Instantiate(g);
             NetworkServer.Spawn(mode);
         }
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         _stop = false;
     }
     // Called when you ask to join a game
     if (Join.GetComponent <ButtonController>().Pressed == true)
     {
         Join.transform.GetComponent <Renderer>().material = Materials[0];
         Lights.GetComponent <ParticleController>().Stop();
         _stop = false;
         _networkManager.GetComponent <NetworkManager>().StartClient();
         PTC.SetActive(true);
         Connecting.SetActive(true);
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         Join.GetComponent <ButtonController>().Pressed = false;
     }
     // Called when you ask to play a single player game
     if (Single.GetComponent <ButtonController>().Pressed == true)
     {
         Single.transform.GetComponent <Renderer>().material = Materials[0];
         Lights.GetComponent <ParticleController>().Stop();
         _stop = false;
         Single.GetComponent <ButtonController>().Pressed = false;
         SinglePlayer = true;
         Store.SetActive(false);
         Single.SetActive(false);
         Title.SetActive(false);
         Online.SetActive(false);
         Controls.SetActive(false);
         Transition(2);
     }
     // Called when you go to the controls menu
     if (Controls.GetComponent <ButtonController>().Pressed == true)
     {
         Controls.transform.GetComponent <Renderer>().material = Materials[0];
         Controls.GetComponent <ButtonController>().Pressed    = false;
         Controls.SetActive(false);
         Guide.SetActive(true);
         Store.SetActive(false);
         Single.SetActive(false);
         Title.SetActive(false);
         Online.SetActive(false);
         BackTL.SetActive(true);
         Transition(2);
     }
     // Called when you press the back button in the store or controls menu
     if (BackTL.GetComponent <ButtonController>().Pressed == true)
     {
         BackTL.GetComponent <ButtonController>().Pressed = false;
         BackTL.SetActive(false);
         Shop.SetActive(false);
         Guide.SetActive(false);
         Store.SetActive(true);
         Single.SetActive(true);
         Title.SetActive(true);
         Online.SetActive(true);
         Controls.SetActive(true);
         Transition(1);
     }
     // If you're trying to join a server but cancel
     if (Input.GetKeyDown(KeyCode.Escape) && Connecting.activeSelf)
     {
         _networkManager.GetComponent <NetworkManager>().StopClient();
         PTC.SetActive(false);
         Connecting.SetActive(false);
         Transition(1);
     }
     // When you actually connecct to the server hide all the extra buttons
     if (NetworkController.GetComponent <NetworkController>().Server || NetworkController.GetComponent <NetworkController>().Client)
     {
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         PTC.SetActive(false);
         Connecting.SetActive(false);
     }
 }