示例#1
0
 private void Start()
 {
     currentSpeed = normalSpeed;
     controller   = GetComponent <CharacterController>();
     StartCoroutine(Move());
     wfs = new WaitForSeconds(waitTime);
 }
示例#2
0
    private void OnEnable()
    {
        var randomNum = Random.Range(0, SpeedOptions.Count - 1);

        for (int i = 0; i < SpeedOptions.Count - 1; i++)
        {
            if (i == randomNum)
            {
                RandomSpeed = SpeedOptions[i];
            }
        }
    }
示例#3
0
    private IEnumerator Move()
    {
        canMove = true;
        pigAnimator.SetBool("isRunning", true);
        while (canMove)
        {
            yield return(wffu);

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                pigAnimator.SetBool("isIdle", false);
                pigAnimator.SetBool("isIdle", true);
                moveSpeed = fastSpeed;
            }

            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                moveSpeed = normalSpeed;
                pigAnimator.SetBool("isIdle", true);
                pigAnimator.SetBool("isIdle", false);
            }

            var vInput = Input.GetAxis("Vertical") * moveSpeed.value;

            movement.Set(vInput, yVar, 0);

            var hInput = Input.GetAxis("Horizontal") * Time.deltaTime * rotateSpeed;
            transform.Rotate(0, hInput, 0);

            yVar += gravity * Time.deltaTime;

            if (controller.isGrounded && movement.y < 0)
            {
                pigAnimator.SetBool("isJumping", false);
                pigAnimator.SetBool("isIdle", true);
                pigAnimator.SetBool("isRunning", true);
                yVar      = -1f;
                jumpCount = 0;
            }

            if (Input.GetButtonDown("Jump") && jumpCount < playerJumpCount.value)
            {
                pigAnimator.SetBool("isIdle", false);
                pigAnimator.SetBool("isJumping", true);
                yVar = jumpForce;
                jumpCount++;
            }

            movement = transform.TransformDirection(movement);
            controller.Move((movement) * Time.deltaTime);
        }
    }
示例#4
0
    private void Awake()
    {
        floatData temp = new floatData();
        bool      v    = saveLoad.Load("Delay", Application.dataPath, out temp);

        if (temp != null)
        {
            if (temp.Data != 0)
            {
                delay = temp.Data;
            }
        }
    }
示例#5
0
 // Use this for initialization
 void Start()
 {
     floatData[] datas = GetComponents <floatData>();
     foreach (floatData d in datas)
     {
         if (d.MyName == data1)
         {
             _data1 = d;
         }
         if (d.MyName == data2)
         {
             _data2 = d;
         }
     }
 }
示例#6
0
    private IEnumerator Move()
    {
        canMove = true;
        while (canMove)
        {
            yield return(wffu);

            yVar += gravity * Time.deltaTime;
            var vInput = Input.GetAxis("Vertical") * currentSpeed.value * Time.deltaTime;
            var hInput = Input.GetAxis("Horizontal") * currentSpeed.value * Time.deltaTime;
            if (controller.isGrounded && movement.y < 0)
            {
                yVar      = -1;
                jumpCount = 0;
            }

            if (Input.GetButtonDown("Jump") && jumpCount < playerJumpMax.value)
            {
                yVar = jumpForce.value;
                jumpCount++;
            }


            if (Input.GetButtonDown("Fire3"))
            {
                currentSpeed = fastSpeed;
            }
            else if (Input.GetButtonUp("Fire3"))
            {
                currentSpeed = normalSpeed;
            }

            lookDirection.Set(hInput, 0, vInput);
            if (hInput > 0.05f || hInput < -0.05f || vInput > 0.05f || vInput < -0.05f)
            {
                finalDirection.Set(lookDirection.x, 0, lookDirection.z);
            }

            if (lookDirection != Vector3.zero)
            {
                transform.rotation = Quaternion.LookRotation(finalDirection);
            }

            movement.Set(hInput, yVar, vInput);
            controller.Move(movement);
        }
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        vector3Data[] vDatas = GetComponents <vector3Data>();
        foreach (vector3Data v3d in vDatas)
        {
            if (v3d.MyName == vectorData)
            {
                _vectorData = v3d;
            }
        }

        floatData[] fDatas = GetComponents <floatData>();
        foreach (floatData f in fDatas)
        {
            if (f.MyName == FloatData)
            {
                _floatData = f;
            }
        }
    }
示例#8
0
    // Use this for initialization
    void Start()
    {
        floatData[]   intDatas = GetComponents <floatData>();
        vector3Data[] v3Datas  = GetComponents <vector3Data>();

        foreach (floatData iData in intDatas)
        {
            if (iData.MyName == intData)
            {
                input = iData;
            }
        }

        foreach (vector3Data v3Data in v3Datas)
        {
            if (v3Data.MyName == vector3Data)
            {
                output = v3Data;
            }
        }
    }
示例#9
0
    void Dispatch()
    {
        for (int i = 0; i < actions.Count; i++)
        {
            popupResponse resp = actions[i];
            switch (resp.action)
            {
            case (popupAction.LoadLevel1):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_Level1);
                    //this.gameObject.SetActive(false);//enabled = false;
                }
                break;
            }

            case (popupAction.LoadLevel2):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_Level2);
                    //this.gameObject.SetActive(false);//enabled = false;
                }
                break;
            }

            case (popupAction.LoadLevel3):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_Level3);
                    //this.gameObject.SetActive(false);//enabled = false;
                }
                break;
            }

            case (popupAction.LoadLevelMainMenu):
            {
                if (gm)
                {
                    gm.ChangeState(gameMgr.eGameState.eGS_MainMenu);
                }
                break;
            }

            case (popupAction.AwardPoints):
            {
                GameObject player = GameObject.Find("Player1");
                if (player)
                {
                    playerData pd = player.GetComponent <playerData>();
                    if (pd)
                    {
                        pd.AddScore(resp.data.id);
                    }
                }
                break;
            }

            case (popupAction.Instantiate):
            {
                if (gm)
                {
                    GameObject go = (GameObject)Instantiate(resp.data.obj);
                    Vector3    p  = go.transform.position;
                    Quaternion q  = go.transform.rotation;
                    go.transform.position      = Vector3.zero;
                    go.transform.rotation      = Quaternion.identity;
                    go.transform.parent        = GameObject.Find(resp.data.name).transform;
                    go.transform.localPosition = p;
                    go.transform.localRotation = q;
                }
                break;
            }

            case (popupAction.EnableObject):
            {
                resp.data.obj.SetActive(true);
                break;
            }

            case (popupAction.DisableObject):
            {
                resp.data.obj.SetActive(false);
                break;
            }

            case (popupAction.HideGameObject):
            {
                resp.data.obj.SetActive(false);
                break;
            }

            case (popupAction.ShowGameObject):
            {
                resp.data.obj.SetActive(true);
                break;
            }

            case (popupAction.QuitApplication):
            {
                Application.Quit();
                break;
            }

            case (popupAction.CameraLookUp):
            {
                Camera.main.gameObject.GetComponent <GameCam>().LookUp();
                break;
            }

            case (popupAction.CameraLookPlayer):
            {
                Camera.main.gameObject.GetComponent <GameCam>().LookPlayer();
                break;
            }

            case (popupAction.SelfDestruct):
            {
                Destroy(this.transform.parent.gameObject);
                break;
            }

            case (popupAction.MakeNpcDance):
            {
                // loop over all QuizNpcHelpers, and find the one with id same as r.data.id
                Object[] QuizNpcHelperObjects = Object.FindObjectsOfType(typeof(QuizNpcHelper));
                foreach (Object item in QuizNpcHelperObjects)
                {
                    if ((item as QuizNpcHelper).GetQuizNpcId() == resp.data.id)
                    {
                        (item as QuizNpcHelper).doSuccess = true;
                    }
                }
                break;
            }

            case (popupAction.ClearInventory):
            {
                GameObject player = GameObject.Find("Player1");
                if (player == null)
                {
                    player = GameObject.Find("Player");
                }
                if (player)
                {
                    inventoryMgr im = player.GetComponent <inventoryMgr>();
                    if (im)
                    {
                        im.inventoryObjects.Clear();
                    }
                }
                break;
            }

            case (popupAction.ResetScore):
            {
                GameObject go = GameObject.Find("setupLevel3");
                if (go)
                {
                    floatData initialScore = go.GetComponent <floatData>();
                    if (initialScore)
                    {
                        GameObject player = GameObject.Find("Player1");
                        if (player == null)
                        {
                            player = GameObject.Find("Player");
                        }
                        if (player)
                        {
                            player.GetComponent <playerData>().score = (int)initialScore._floatData;
                        }
                    }
                }
                break;
            }

            case (popupAction.AddMissionToken):
            {
                GameObject mm = GameObject.Find("Game");
                if (mm)
                {
                    missionMgr mmgr = mm.GetComponent <missionMgr>();
                    if (mmgr)
                    {
                        missionToken mt = this.GetComponent <missionToken>();
                        if (mt != null)
                        {
                            mmgr.add(mt);
                        }
                    }
                }
                break;
            }
            }
        }
    }
示例#10
0
 private void Start()
 {
     moveSpeed  = normalSpeed;
     controller = GetComponent <CharacterController>();
     StartCoroutine(Move());
 }
示例#11
0
 private void OnTriggerEnter(Collider other)
 {
     speed = upGrade;
     rb.AddForce(0, 0, speed.Value);
 }
示例#12
0
    public void Save(float delay)
    {
        var v = new floatData(delay);

        saveLoad.Save(v, "Delay", Application.dataPath);
    }