예제 #1
0
    void FixedUpdate()
    {
        PlayerPrefs.SetInt("score", score);
        scoreText.text = score.ToString("");
        //KeepOnTheArena();

        myBody.AddRelativeForce(myBody.transform.TransformDirection(-Vector3.up) * 5);



        //check the position of the joystick and move the player accordingly
        Vector3 moveVec = new Vector3(CrossPlatformInputManager.GetAxis("Vertical"), 0, -CrossPlatformInputManager.GetAxis("Horizontal")) * moveForce;

        if (moveVec != Vector3.zero)
        {
            Dust.SetActive(true);
        }
        else
        {
            Dust.SetActive(false);
        }

        //Look at the right direction
        Vector3 lookVec = new Vector3(-CrossPlatformInputManager.GetAxis("Vertical"), 0, CrossPlatformInputManager.GetAxis("Horizontal"));

        //if the joystick is in the middle we dont change the rotation
        if (lookVec != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(lookVec, Vector3.up);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, 5);
        }


        //change center of mass if shield is on
        if (shield.activeSelf)
        {
            myBody.centerOfMass = new Vector3(0, 0, 1.85f);
        }
        else
        {
            myBody.ResetCenterOfMass();
        }

        //Keep it on the ground

        if (this.transform.position.y > 2)
        {
            toohigh = true;
        }
        else
        {
            toohigh = false;
        }

        if (toohigh == true)
        {
            KeepOnTheArena();
        }

        //dashbutton
        bool isBoosting   = CrossPlatformInputManager.GetButtonDown("Boost");
        bool stopBoosting = CrossPlatformInputManager.GetButtonUp("Boost");

        //shockwave button
        bool isShockwaving = CrossPlatformInputManager.GetButtonDown("Shockwave");

        //shockwave
        if (isShockwaving == true)
        {
            Shockwave();
            isShockwaving = false;
        }



        //dash
        if (dashmeter > 9)
        {
            dashbarover50.SetActive(true);
            if (isBoosting == true)
            {
                myBody.AddForce(-direction.forward * dashspeed);
                dashmeter -= 10;
                //dash.SetActive(true);
                GameObject clone = (GameObject)Instantiate(dashParticle, transform.position, transform.rotation);
                clone.transform.parent = gameObject.transform;
                Destroy(clone, 0.2f);
                StartCoroutine(StopBoosting());

                boostActivated = true;
            }
        }
        else
        {
            dashbarover50.SetActive(false);
        }
        if (isBoosting == false)
        {
            dash.SetActive(false);
        }



        //adding force to the player based on the position of the joystick
        myBody.AddForce(moveVec);



        force = 800;

        //do nothing if no target is found for missile
        if (target == null)
        {
            return;
        }
    }
예제 #2
0
    public void ShowStatusCanvas(BuildingStatus buildingStatus)
    {
        for (int i = 0; i < character.Length; i++)
        {
            character[i].GetComponent <Image>().sprite = buildingStatus.sprite[4];
        }

        building.GetComponent <SpriteRenderer>().sprite = buildingStatus.Building.GetComponent <SpriteRenderer>().sprite;
        building.GetComponent <SpriteRenderer>().color  = buildingStatus.Building.GetComponent <SpriteRenderer>().color;
        building.transform.localScale = buildingStatus.Building.transform.localScale;
        building.GetComponent <SpriteRenderer>().sortingLayerName = "CanvasBuilding";

        for (int i = 0; i < Subbuilding.Length; i++)
        {
            Subbuilding[i].SetActive(buildingStatus.SubBuilding[i].activeSelf);
            Subbuilding[i].GetComponent <SpriteRenderer>().sprite = buildingStatus.SubBuilding[i].GetComponent <SpriteRenderer>().sprite;
            Subbuilding[i].GetComponent <SpriteRenderer>().color  = buildingStatus.SubBuilding[i].GetComponent <SpriteRenderer>().color;
            Subbuilding[i].transform.localPosition = buildingStatus.SubBuilding[i].transform.localPosition;
            Subbuilding[i].GetComponent <SpriteRenderer>().sortingLayerName = "CanvasBuilding";
        }

        Info.SetActive(buildingStatus.INFO.activeSelf);
        Info.GetComponent <SpriteRenderer>().sortingLayerName = "CanvasBuilding";
        Dust.SetActive(buildingStatus.Dust.activeSelf);
        Dust.GetComponent <SpriteRenderer>().sortingLayerName = "CanvasBuilding";

        for (int i = 0; i < Fire.Length; i++)
        {
            Fire[i].SetActive(buildingStatus.Fire[i].activeSelf);
            Fire[i].GetComponent <SpriteRenderer>().sortingLayerName = "CanvasBuilding";
        }


        if (buildingStatus.Hammer.activeSelf)
        {
            Hammer.SetActive(true);
            Hammer.GetComponent <SpriteRenderer>().sortingLayerName = "CanvasBuilding";
            MoveHammer();
        }
        else
        {
            OffHammer();
        }

        NeedPointText.text    = buildingStatus.building.getNeedPopulation().ToString();
        MinPointText.text     = buildingStatus.building.getMinPopulation().ToString();
        ScorePointText.text   = buildingStatus.building.getScore().ToString();
        BuildingNameText.text = buildingStatus.gameObject.name;

        list = buildingStatus.building.getNeedPlayerList();

        for (int i = 0; i < list.Count; i++)
        {
            character[i].GetComponent <Image>().sprite = GM.Character[list[i]];
        }

        BuildingStatusCanvas.GetComponent <Canvas>().sortingLayerName = "Canvas";

        if (ReturnInGameCanvas.activeSelf)
        {
            ReturnInGameCanvas.GetComponent <Canvas>().sortingLayerName = "Default";
        }

        HideUICanvas();
    }