Exemplo n.º 1
0
    void Update()
    {
        if (_stick != null && _stick.GetComponent <MeshRenderer>() != null)
        {
            _stick.GetComponent <MeshRenderer>().enabled = true;
        }

        if (_stick == null)
        {
            Destroy(gameObject);
            return;
        }

        transform.Translate(Vector2.down * _stick.SpeedForce, Space.World);
    }
Exemplo n.º 2
0
    void Update()
    {
        if (IsMoving)
        {
            _stick.transform.transform.Translate(new Vector3(0f, -9f, 0f) * Time.deltaTime);
            _gameController.CurrentPlatform.transform.Translate(new Vector3(-9f, 0f, 0f) * Time.deltaTime);
            _gameController.NextPlatform.transform.Translate(new Vector3(-9f, 0f, 0f) * Time.deltaTime);
        }

        if (_gameController.CurrentPlatform.transform.position.x >= -targerPosition)
        {
            return;
        }

        IsMoving = false;

        if (IsFalling)
        {
            _stick.GetComponent <Stick>().enabled = false;
            transform.Translate(Vector3.down * Time.deltaTime * 10f);

            if (transform.position.y < -4f)
            {
                IsFalling = false;
                _gameController.CurrentState        = new Defeat(_gameController);
                _gameController.TextRestart.enabled = true;
                this.gameObject.SetActive(false);
            }
        }
        else
        {
            _gameController.CreateNewPlatform();
        }
    }
Exemplo n.º 3
0
    public override void OnClick()
    {
        GameObject newEndItem = Instantiate(endItemPrefab.gameObject, playField.transform);

        newEndItem.transform.rotation = stick.transform.rotation;
        newEndItem.transform.position = stick.transform.position + new Vector3(0, stick.GetComponent <MeshRenderer>().bounds.extents.y, transform.position.z);

        newEndItem.transform.rotation = transform.rotation;
        Vector3 normalizedDir = (transform.position - stick.transform.position).normalized;
        Vector3 dir1or0       = new Vector3(Mathf.RoundToInt(normalizedDir.x), Mathf.RoundToInt(normalizedDir.y), 0);

        newEndItem.transform.position = stick.transform.position + (dir1or0 * jointOffset);

        stick.AddFixedJoint();
        stick.ConnectRigidBody(newEndItem.GetComponent <Rigidbody>());
        newEndItem.GetComponent <EndItem>().attachedToStick = stick.GetComponent <Rigidbody>();
        arrows.SetActive(false);
        newEndItem.GetComponent <EndItem>().arrows = arrows;
    }
Exemplo n.º 4
0
    public override void StartObjective(Task task = null)
    {
        base.StartObjective(task);
        objectiveTimeLeft = timeLimit;
        stick             = Instantiate(stickPrefab, GameManager.Instance.Owner.throwFrom.position, Quaternion.identity);
        stick.fetchObj    = this;
        Rigidbody2D rb  = stick.GetComponent <Rigidbody2D>();
        float       x   = Random.Range(-16f, -6f);
        float       y   = Random.Range(7, 12);
        Vector2     vel = new Vector2(x, y);

        rb.AddForce(vel, ForceMode2D.Impulse);
        rb.AddTorque(0.05f * vel.magnitude, ForceMode2D.Impulse);

        GameManager.Instance.Owner.GetComponentInParent <Animator>().SetTrigger("Throwing");
    }
Exemplo n.º 5
0
        //Hypersticks
        private void CreateCylinderByShader(int start)
        {
            GameObject Stick;
            int        i = start;

            int[] atomsIds = bondEPList[i] as int[];
            Stick = GameObject.CreatePrimitive(PrimitiveType.Cube);
            RuntimePlatform platform = Application.platform;

            switch (platform)
            {
            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.WindowsWebPlayer:
            case RuntimePlatform.WindowsEditor:
                Stick.GetComponent <Renderer>().material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;

            default:
                Stick.GetComponent <Renderer>().material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;
            }
            StickUpdate comp = Stick.AddComponent <StickUpdate>();

            //Debug.Log("BOND : " + atomsIds[0] + " - " + atomsIds[1]);
            //comp.atompointer1=(GameObject)MoleculeModel.atoms[atomsIds[0]];
            //comp.atompointer2=(GameObject)MoleculeModel.atoms[atomsIds[1]];

            if (UI.UIData.atomtype == UI.UIData.AtomType.particleball)
            {
                comp.atompointer1 = (GameObject)MoleculeModel.atoms[atomsIds[0]];
                comp.atompointer2 = (GameObject)MoleculeModel.atoms[atomsIds[1]];
            }
            else
            {
                GenericManager manager = Molecule.View.DisplayMolecule.GetManagers()[0];
                comp.atompointer1 = manager.GetBall(Molecule.Model.MoleculeModel.atoms.Count - 1 - atomsIds[0]);
                comp.atompointer2 = manager.GetBall(Molecule.Model.MoleculeModel.atoms.Count - 1 - atomsIds[1]);
            }

            comp.enabled = true;
            Stick.GetComponent <Renderer>().material.SetFloat("_Shrink", StickUpdate.shrink);
            Stick.tag = "Club";
            Stick.GetComponent <Collider>().enabled = false;
            Stick.transform.position = comp.atompointer1.transform.position;
            Stick.transform.parent   = BondCubeParent.transform;
        }
Exemplo n.º 6
0
    private void OnTriggerEnter(Collider other)
    {
        Rigidbody rb = other.attachedRigidbody;

        if (rb == null)
        {
            return;
        }

        List <Item> itens = new List <Item>();

        //Check if it's a stick
        Stick stick = rb.GetComponent <Stick>();

        if (stick != null)
        {
            for (int i = 0; i < stick.grabbedItens.Count; i++)
            {
                CookableFood food = stick.grabbedItens[i].GetComponent <CookableFood>();

                //The ingredient is only valid if it's not raw nor burnt
                if (food != null && food.state != CookState.WellDone)
                {
                    continue;
                }

                Item stickItem = stick.grabbedItens[i].GetComponent <Item>();
                itens.Add(stickItem);
            }

            stick.GetComponent <PoolableObject>().ReturnToPool();
        }
        else
        {
            //Anything that is not in a stick
            Item item = rb.GetComponent <Item>();

            if (item != null)
            {
                itens.Add(item);
            }
        }

        orderDelivered?.Invoke(itens);
    }
Exemplo n.º 7
0
        //Billboard hypersticks
        private void CreateBBCylinderByShader(int i)
        {
            GameObject Stick;

            if (UIData.toggleClip)
            {
                Stick = Clip4HyperStick.CreateClip();
            }
            else
            {
                Stick = GameObject.CreatePrimitive(PrimitiveType.Plane);
            }

            int[] atomsIds = bondEPList[i] as int[];

            Stick.transform.Rotate(new Vector3(0, -180, 0));
            Stick.AddComponent("CameraFacingBillboard");
            Stick.GetComponent <CameraFacingBillboard>().cameraToLookAt = GameObject.Find("Camera").camera;
            RuntimePlatform platform = Application.platform;

            switch (platform)
            {
            case RuntimePlatform.WindowsPlayer:
            case RuntimePlatform.WindowsWebPlayer:
            case RuntimePlatform.WindowsEditor:
                Stick.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;

            default:
                Stick.renderer.material.shader = Shader.Find("FvNano/Stick HyperBalls 2 OpenGL");
                break;
            }
            Stick.AddComponent("StickUpdate");

            StickUpdate comp = Stick.GetComponent <StickUpdate>();

            comp.atompointer1 = (GameObject)MoleculeModel.atoms[atomsIds[0]];
            comp.atompointer2 = (GameObject)MoleculeModel.atoms[atomsIds[1]];

            comp.enabled = true;
            Stick.renderer.material.SetFloat("_Shrink", 0.01f);
            Stick.tag = "Club";
            Stick.transform.parent = BondCubeParent.transform;
        }
Exemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            derece  = new Vector2(Mathf.Cos(Player_Object.obje.transform.rotation.eulerAngles.z * Mathf.PI / 180), (Mathf.Sin(Player_Object.obje.transform.rotation.eulerAngles.z * Mathf.PI / 180)));
            derece2 = new Vector2(Mathf.Cos((Player_Object.obje.transform.rotation.eulerAngles.z + 90) * Mathf.PI / 180), (Mathf.Sin((Player_Object.obje.transform.rotation.eulerAngles.z + 90) * Mathf.PI / 180)));
            derece3 = new Vector2(Mathf.Cos((Player_Object.obje.transform.rotation.eulerAngles.z + 180) * Mathf.PI / 180), (Mathf.Sin((Player_Object.obje.transform.rotation.eulerAngles.z + 180) * Mathf.PI / 180)));
            derece4 = new Vector2(Mathf.Cos((Player_Object.obje.transform.rotation.eulerAngles.z + 270) * Mathf.PI / 180), (Mathf.Sin((Player_Object.obje.transform.rotation.eulerAngles.z + 270) * Mathf.PI / 180)));

            Player_Object.angle = new Vector2(Player_Object.obje.transform.rotation.eulerAngles.z, 0);

            //float rotation = Input.GetAxis("Vertical") * 100;
            if (Player_Object.attached00 == true)
            {
                move.jumpHeight          = derece;
                Player_Object.attached00 = false;
            }
            else if (Player_Object.attached01 == true)
            {
                move.jumpHeight          = derece2;
                Player_Object.attached01 = false;
            }
            else if (Player_Object.attached10 == true)
            {
                move.jumpHeight          = derece3;
                Player_Object.attached10 = false;
            }
            else if (Player_Object.attached11 == true)
            {
                move.jumpHeight          = derece4;
                Player_Object.attached11 = false;
            }

            Destroy(Player_Object.GetComponent <HingeJoint2D>());
            Player_Object.attached = false;
            move.speed             = hiz;
        }
    }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (Stick.GetComponent <DetectCliks> ())
        {
            if (!IsReady && DetectsClick.GetComponent <DetectCliks> ().GetStickReadyToCheck())
            {
                DetectsClick.GetComponent <DetectCliks> ().SetStickReadyToCheck(false);
                if ((Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2 < SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x
                     - SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.localScale.x / 2 - Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x) ||
                    (Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2 > SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x
                     + SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.localScale.x / 2 - Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x))
                {
                    IsWin = false;
                    AudioSource.PlayClipAtPoint(Clip_Lose, new Vector3(0f, 0f, 0f));
                }
                else
                {
                    IsWin = true;
                    AudioSource.PlayClipAtPoint(Clip_done, new Vector3(0f, 0f, 0f));
                    DetectsClick.GetComponent <SpawnBlock> ().SetIsSpawn(false);
                }
            }
        }

        if (Player.transform.position.y < -6f)
        {
            Destroy(Player);
        }
        if (IsWin && Player)
        {
            if (SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x != Player.transform.position.x)
            {
                if (DetectsClick.GetComponent <DetectCliks> ().GetPlayerIsReady() == true)
                {
                    Player.transform.position = Vector3.MoveTowards(Player.transform.position,
                                                                    new Vector3(SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x, -0.25f, -8f), Time.deltaTime * 3);
                }
            }

            if (SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x <= Player.transform.position.x)
            {
                IsReady = true;
                Player.transform.position = (new Vector3(SpawnBlock.GetComponent <SpawnBlock> ().GetblockInstNext().transform.position.x, -0.25f, -8f));
                Allblock.GetComponent <MoveBlocks> ().SetOnPlace(false);
                enabled = false;
            }
        }
        else
        {
            if (IsReadyToDown == false && (Player.transform.position != new Vector3(Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x
                                                                                    + Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2, -0.25f, -8f) && IsReadyToDown == false))
            {
                Player.transform.position = Vector3.MoveTowards(Player.transform.position,
                                                                new Vector3(Stick.GetComponent <DetectCliks> ().GetStickInst().transform.position.x
                                                                            + Stick.GetComponent <DetectCliks> ().GetStickInst().transform.localScale.y / 2, -0.25f, -8f), Time.deltaTime * 3);
            }
            else
            {
                // audio proigr
                IsReadyToDown = true;
                IsReady       = true;
                Player.GetComponent <MovePlayer> ().SetIsWin(false);
                Player.transform.Translate(new Vector3(0f, -8f, 0f) * Time.deltaTime);
            }
        }
    }