Exemple #1
0
    IEnumerator Back()
    {
        //玩家与分身初始位置向量获得
        Vector2 v = this.transform.position - player.transform.position;

        while (GetV(v) >= 0.5f)
        {
            if (TCKInput.GetTouchPhase("Joystick") == ETouchPhase.NoTouch)
            {
                yield return(0);

                continue;
            }

            //玩家与分身位置向量获得
            v = this.transform.position - player.transform.position;

            //分身朝玩家位置移动
            transform.Translate(-v * Time.deltaTime * 2);
            yield return(0);
        }

        //分身收回
        player.GetComponent <PlayerActivity>().count += 1;

        //吃掉敌人回复精力值
        player.GetComponent <PlayerActivity>().Energy.GetComponent <Energy>().time = 3;

        //消灭分身object
        GameObject.Destroy(this.gameObject);
    }
Exemple #2
0
    public IEnumerator Back()
    {
        this.gameObject.GetComponent <CircleCollider2D>().isTrigger = true;


        //玩家与分身初始位置向量获得
        Vector2 v = this.transform.position - player.transform.position;

        rigid.velocity *= 0;

        while (GetV(v) >= 0.5f)
        {
            if (TCKInput.GetTouchPhase("Joystick") == ETouchPhase.NoTouch)
            {
                if (isDestroy)
                {
                    isDestroy = false;
                    break;
                }
                yield return(0);

                continue;
            }

            if (isDestroy)
            {
                break;
            }

            //玩家与分身位置向量获得
            v = this.transform.position - player.transform.position;

            //分身朝玩家位置移动
            transform.Translate(-v * Time.deltaTime * 2);

            yield return(0);
        }

        isDestroy = true;
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        this.transform.rotation = Quaternion.identity;


        //UI显示用(当前可射出分身数量)
        text.GetComponent <Text>().text = count.ToString();

        this.gameObject.transform.localScale = new Vector2(count / 5, count / 5);

        if (TCKInput.GetTouchPhase("Joystick") == ETouchPhase.Stationary || TCKInput.GetTouchPhase("Joystick") == ETouchPhase.Moved)
        {
            if (Energy.GetComponent <Energy>().time > 0)
            {
                Energy.GetComponent <Energy>().time -= Time.deltaTime;

                //子弹时间开启
                Time.timeScale = 0.3f;
            }

            if (pressTime >= 0)
            {
                pressTime -= Time.deltaTime;
            }

            if (Energy.GetComponent <Energy>().time <= 0)
            {
                //子弹时间关闭
                Time.timeScale = 1.0f;
            }

            if (pressTime <= 0)
            {
                joystick.GetComponent <TCKJoystick>().touchDown  = false;
                joystick.GetComponent <TCKJoystick>().touchPhase = ETouchPhase.NoTouch;

                isOverTime    = true;
                isTouchUp     = true;
                isCancelShoot = false;
            }

            //获取移动方向
            move = TCKInput.GetAxis("Joystick");

            if (Mathf.Abs(move.x) <= 0.3f && Mathf.Abs(move.y) <= 0.3f)
            {
                //取消发射判定
                isCancelShoot = true;
            }
            else
            {
                isCancelShoot = false;
            }
        }
        else
        {
            Time.timeScale = 1.0f;

            if (Energy.GetComponent <Energy>().time <= 3)
            {
                Energy.GetComponent <Energy>().time += 0.05f * Time.deltaTime;
            }
        }

        //移动(生成分身)
        if (isTouchUp && count > 1 && !isCancelShoot)
        {
            // Debug.Log("Shoot");
            // rigid.velocity += move;

            Shoot(move);

            //如果已经有移动线程 先关闭
            if (coroutine != null)
            {
                StopCoroutine(coroutine);
                coroutine = null;
            }

            //移动线程
            coroutine = StartCoroutine(Move(move.normalized * 2));
        }

        // //重置开火状态
        isTouchUp = false;
    }
Exemple #4
0
 void TouchEvent()
 {
     //    Debug.Log(TCKInput.GetTouchPhase("leftJoystick").ToString() == "Stationary");
     Debug.Log("jsk" + TCKInput.GetTouchPhase("Joystick"));
 }