Пример #1
0
    // Update is called once per frame
    void Update()
    {
        //each frame, set my position to
        if (timer >= 0.01667f)
        {
            if (newPositions.Count > 0)
            {
                transform.position = newPositions[0];
                newPositions.RemoveAt(0);
            }
            timer += TimeStopController.deltaTime() - 0.01667f;
        }
        else
        {
            timer += TimeStopController.deltaTime();
        }

        if (stuck)
        {
            print("hello?");
            rb.velocity = Vector3.zero;
            useGravity  = true;
        }

        //print(rb.velocity + "/" + (Physics.gravity * TimeStopController.getTimeScale()));

        if (useGravity)
        {
            print("hello");
            transform.GetChild(0).GetComponent <Animator>().SetBool("bombOpen", true);
            rb.AddForce(Physics.gravity * TimeStopController.getTimeScale());
        }

        transform.GetChild(0).GetComponent <Animator>().speed = 1 * TimeStopController.timeScale;
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastSpawn      += TimeStopController.deltaTime();
        timeSinceLastEnemySpawn += TimeStopController.deltaTime();
        if (timeSinceLastSpawn > spawnInterval)
        {
            timeSinceLastSpawn = 0.0f;
            if (spawnInterval > 1.2f)
            {
                spawnInterval *= 0.97f;
            }
            Instantiate(enemGO, transform).transform.localScale = new Vector3(2, 1, 2);//new Vector3(2 * 1.4f, 1 * 1.4f, 2 * 1.4f);

            //GameObject newGo  = Instantiate(enemGO, transform.position, Quaternion.identity);
            //newGo.transform.position = new Vector3(newGo.transform.position.x, 1.4f, newGo.transform.position.z);
        }

        if (timeSinceLastEnemySpawn > enemyInterval)
        {
            timeSinceLastEnemySpawn = 0.0f;
            if (enemyInterval > 1.4f)
            {
                enemyInterval *= 0.97f;
            }
            GameObject newGO = Instantiate(attackerGO, transform);
            newGO.transform.localScale = new Vector3(2, 1, 2);
            Vector3 newPos = newGO.transform.position;
            newPos.y = 1.25f;
            newGO.transform.position = newPos;
            //GameObject newGo = Instantiate(attackerGO, transform.position, Quaternion.identity);
            //    newGo.transform.position = new Vector3(newGo.transform.position.x, 1.4f, newGo.transform.position.z);
        }
    }
Пример #3
0
    private void Update()
    {
        Vector3 newPos = transform.position;

        newPos.y           = startY + Mathf.Sin(TimeStopController.currentTime * 3) * 0.3f;
        transform.position = newPos;
        transform.Rotate(Vector3.up * 45 * TimeStopController.deltaTime());
    }
Пример #4
0
    private void Start()
    {
        TSC = GameObject.Find("TimeStopController").GetComponent <TimeStopController>();
        rb  = GetComponent <Rigidbody>();

        currentLifeTime = lifeTime;

        topVal = startVal * startValFactor;
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastSpawn += TimeStopController.deltaTime();

        if (timeSinceLastSpawn > pickUpRespawnTime)
        {
            spawnPickup();
            pickUpRespawnTime *= 0.9f;
            timeSinceLastSpawn = 0;
        }
    }
Пример #6
0
 // Update is called once per frame
 void Update()
 {
     if (currentTransCD > 0)
     {
         currentTransCD -= TimeStopController.deltaTime();
     }
     if (currentBombCD > 0)
     {
         currentBombCD -= TimeStopController.deltaTime();
     }
 }
Пример #7
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         DestroyObject(gameObject);
     }
     DontDestroyOnLoad(this);
 }
Пример #8
0
    private void Update()
    {
        if (currentLifeTime <= 0)
        {
            Destroy(this.gameObject);
        }
        else
        {
            currentLifeTime -= Time.deltaTime * TimeStopController.timeScale;
        }

        rb.velocity = topVal * TimeStopController.getTimeScale(); //Stop mid air
    }
Пример #9
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //rb.velocity = Vector3.zero;

        transform.GetChild(0).GetComponent <Animator>().speed = 1 * TimeStopController.timeScale;
        Animator anim = transform.GetChild(0).GetComponent <Animator>();

        bool    isWalking = false;
        Vector3 lookAt    = player.transform.position;

        lookAt.y = transform.position.y;
        transform.LookAt(lookAt);
        if (Vector3.Distance(transform.position, player.transform.position) >= minDistance && TimeStopController.timeScale >= 0.01f)
        {
            isWalking           = true;
            transform.position += (transform.forward * speed * TimeStopController.deltaTime());
            //print((transform.forward * speed * TimeStopController.deltaTime()));
            if (Vector3.Distance(transform.position, player.transform.position) <= minDistance + 1)
            {
                isWalking = false;
                //play attack anim
                print("Attacku!");
                anim.SetBool("isAttacking", true);
            }
            else
            {
                anim.SetBool("isAttacking", false);
                if (!anim.GetCurrentAnimatorStateInfo(0).IsName("enemyWalkWeapon"))
                {
                    anim.Play("enemyWalkWeapon");
                }
            }
        }

        if (isWalking)
        {
            anim.SetBool("isAttacking", false);
            if (!anim.GetCurrentAnimatorStateInfo(0).IsName("enemyWalkWeapon"))
            {
                anim.Play("enemyWalkWeapon");
            }
        }
        //rb.AddForce(Physics.gravity * TimeStopController.timeScale);
    }
Пример #10
0
    public static IEnumerator moveObject(GameObject go, Vector3 direction, float duration, float distance, INTERPOLATION_TYPE type = INTERPOLATION_TYPE.SMOOTH, int power = 1) //direction normalized
    {
        Vector3 startPos = go.transform.localPosition;

        System.Func <float, float> interpolationFunc = getInterpolationFunc(type);
        //float delta = 0.0f;
        //float oldPos = 0.0f;
        float newPos = 0.0f;

        for (float i = 0; i < duration; i += TimeStopController.deltaTime())
        {
            //float pd = 0.25f + (i * 0.75f / duration); //TODO: make this line better mebbe
            float pd = i / duration; //TODO: ???
            newPos = interpolationFunc(pd);
            newPos = Mathf.Pow(newPos, power);
            //delta = newPos - oldPos;
            //oldPos = newPos;
            go.transform.localPosition = startPos + (direction * newPos * distance);
            yield return(null);
        }
        go.transform.localPosition = startPos + (direction * distance);
    }
Пример #11
0
 // Update is called once per frame
 void Update()
 {
     //Time.deltaTime* TimeStopController.timeScale == TimeStopController.instance.deltaTimeScale;
     ps.Simulate(TimeStopController.deltaTime(), true, false);
 }
Пример #12
0
 // Use this for initialization
 void Start()
 {
     rb  = GetComponent <Rigidbody>();
     TSC = GameObject.Find("TimeStopController").GetComponent <TimeStopController>();
 }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     TSC = TimeStopController.instance.GetComponent <TimeStopController>();
 }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        //GetComponentInChildren<Animator>().speed = TimeStopController.timeScale;

        transform.GetChild(1).GetComponent <Animator>().speed = 1 * TimeStopController.timeScale;
        transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().speed = TimeStopController.timeScale;
        int   lerpSpeed   = 10;
        float targetScale = 1;

        if (Input.GetKeyUp(KeyCode.Mouse0) && !GC.pauseGameObj.activeSelf && !GC.gameOverObj.activeSelf)
        {
            print("Mouse0: Trans-Shoot");
            gunPrefab.GetComponent <GunController>().shootTrans();
            targetScale = 0.5f;
            transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().Play("Gun_Fire");
            StartCoroutine(wait(1));
        }
        else if (Input.GetKeyUp(KeyCode.Mouse1) && !GC.pauseGameObj.activeSelf && !GC.gameOverObj.activeSelf)
        {
            print("Mouse0: Bomb-Shoot");
            if (GameController.instance.haveBombs())
            {
                if (gunPrefab.GetComponent <GunController>().throwBomb(transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>()))
                {
                    //same as above
                    targetScale = 0.5f;
                    GameController.instance.spendBombs(1);
                    transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isPredictingBomb", false);
                }
            }
        }
        if (!transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().GetBool("isPredictingBomb"))
        {
            gunPrefab.SetActive(true);
            BombPrefabHand.SetActive(false);
        }

        if (Input.GetKey(KeyCode.Mouse1))
        {
            gunPrefab.GetComponent <GunController>().bombPrediction();
            transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isPredictingBomb", true);
            gunPrefab.SetActive(false);
            BombPrefabHand.SetActive(true);
        }
        else
        {
            gunPrefab.GetComponent <GunController>().destroyDots();
        }

        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D))
        {
            targetScale = 1;
        }
        else
        {
            targetScale = 0;
            lerpSpeed   = 4;
        }
        if (Input.GetKey(KeyCode.LeftShift))
        {
            transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isRunning", true);
        }
        else
        {
            transform.GetChild(0).transform.GetChild(0).GetComponent <Animator>().SetBool("isRunning", false);
        }

        TSC.setTimeScale(Mathf.Lerp(TimeStopController.getTimeScale(), targetScale, Time.deltaTime * lerpSpeed));
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     TSC = GameObject.Find("TimeStopController").GetComponent <TimeStopController>();
     GC  = GameObject.Find("GameController").GetComponent <GameController>();
 }