Example #1
0
    override public bool Create()
    {
        if (base.Create() == false)
        {
            return(false);
        }
        m_fSpeed = 340.0f;

        m_stPos.y = m_fGroundY;

        m_eDirect = E_CSDIRECT.E_RIGHT;
        m_stPos.x = 460.0f;

        if (CSRandom.Rand(0, 100) < 50)
        {
            m_eDirect   = E_CSDIRECT.E_LEFT;
            m_stPos.x   = -460.0f;
            m_stScale.x = -1.0f;
            m_pParticle_Left.gameObject.SetActive(true);
        }
        else
        {
            m_pParticle_Right.gameObject.SetActive(true);
            m_fSpeed *= -1.0f;
        }
        JHGame_MainLayer.I.m_pEffect_Mng.CreateEffect_Danger(m_eDirect);

        StartCoroutine(Cor_CowStart());
        return(true);
    }
Example #2
0
    override public bool Create()
    {
        if (base.Create() == false)
        {
            return(false);
        }
        m_fSpeed = 280.0f;

        m_stPos.y = m_fGroundY;

        m_eDirect = E_CSDIRECT.E_RIGHT;
        m_stPos.x = 480.0f;

        if (CSRandom.Rand(0, 100) < 50)
        {
            m_eDirect   = E_CSDIRECT.E_LEFT;
            m_stPos.x   = -480.0f;
            m_stScale.x = -1.0f;
        }
        else
        {
            m_fSpeed *= -1.0f;
        }
        JHGame_MainLayer.I.m_pEffect_Mng.CreateEffect_Danger(m_eDirect);

        StartCoroutine(Cor_CarStart());
        return(true);
    }
Example #3
0
    void GSensor()
    {
        float fPosX = Input.acceleration.x;

        if (Input.touchCount >= 1)
        {
            ChangeState(E_HEROSTATE.E_JUMP);
        }

        if (Mathf.Abs(fPosX) < 0.06f)
        {
            if (fPosX == 0.0f)
            {
                return;
            }
            ChangeState(E_HEROSTATE.E_NONE);
            return;
        }



        if (fPosX < 0.0f)
        {
            m_eDirect = E_CSDIRECT.E_LEFT;
            m_pSprite.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
            m_bMove = true;
        }
        else
        {
            m_eDirect = E_CSDIRECT.E_RIGHT;
            m_pSprite.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
            m_bMove = true;
        }
        if (m_bMove == true)
        {
            if (m_eDirect == E_CSDIRECT.E_LEFT)
            {
                m_stPos.x -= m_fSpeed * Time.deltaTime;
                if (m_stPos.x <= -m_fWallX)
                {
                    m_stPos.x = -m_fWallX;
                }
            }
            else if (m_eDirect == E_CSDIRECT.E_RIGHT)
            {
                m_stPos.x += m_fSpeed * Time.deltaTime;
                if (m_stPos.x >= m_fWallX)
                {
                    m_stPos.x = m_fWallX;
                }
            }
            ChangeState(E_HEROSTATE.E_MOVE);
        }
    }
Example #4
0
 void Start()
 {
     m_pColor        = Color.white;
     m_pColor.a      = 0.0f;
     m_pBack.color   = m_pColor;
     m_pCenter.color = m_pColor;
     m_eDirect       = E_CSDIRECT.E_CENTER;
     if (centerOnPress)
     {
         StartCoroutine("fadeOutJoystick");
     }
 }
Example #5
0
    public CSObjectStruct <JHEffect_Root> CreateEffect_Danger(E_CSDIRECT eDirect)
    {
        CSObjectStruct <JHEffect_Root> pObject = new CSObjectStruct <JHEffect_Root>();
        JHEffect_CowDanger             pSrc    = null;

        pObject.pObj = CSPrefabMng.I.CreatePrefab(transform.name, "2_Objects/Effect/Effect_CowDanger", "Effect_" + m_nSpawnCnt.ToString());
        pSrc         = pObject.pObj.GetComponent <JHEffect_CowDanger>();
        pSrc.Enter();
        pSrc.Create(eDirect);
        pObject.pSrc = (JHEffect_Root)pSrc;

        m_pList.Add(pObject);
        m_nSpawnCnt++;
        return(pObject);
    }
Example #6
0
    void Joypad()
    {
        if (Input.touchCount >= 2)
        {
            ChangeState(E_HEROSTATE.E_JUMP);
        }

        if (JHGame_UILayer.I.m_pJoyStick.m_eDirect == E_CSDIRECT.E_CENTER)
        {
            ChangeState(E_HEROSTATE.E_NONE);
            return;
        }



        if (JHGame_UILayer.I.m_pJoyStick.m_eDirect == E_CSDIRECT.E_LEFT)
        {
            m_eDirect = E_CSDIRECT.E_LEFT;
            m_pSprite.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
            m_bMove = true;
        }
        else if (JHGame_UILayer.I.m_pJoyStick.m_eDirect == E_CSDIRECT.E_RIGHT)
        {
            m_eDirect = E_CSDIRECT.E_RIGHT;
            m_pSprite.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
            m_bMove = true;
        }
        if (m_bMove == true)
        {
            if (m_eDirect == E_CSDIRECT.E_LEFT)
            {
                m_stPos.x -= m_fSpeed * Time.deltaTime;
                if (m_stPos.x <= -m_fWallX)
                {
                    m_stPos.x = -m_fWallX;
                }
            }
            else if (m_eDirect == E_CSDIRECT.E_RIGHT)
            {
                m_stPos.x += m_fSpeed * Time.deltaTime;
                if (m_stPos.x >= m_fWallX)
                {
                    m_stPos.x = m_fWallX;
                }
            }
            ChangeState(E_HEROSTATE.E_MOVE);
        }
    }
Example #7
0
    /// <summary>
    /// Apply the dragging momentum.
    /// </summary>

    void Update()
    {
        if (JHGameData_Mng.I._GSencer == false)
        {
            return;
        }
        if (JHGameData_Mng.I._GamePause == true)
        {
            return;
        }
        if (JHGameData_Mng.I._GameCycle == true)
        {
            return;
        }


        if (Input.GetMouseButtonDown(0))
        {
            if (mPressed == false)
            {
                Vector3 st = JHGame_Scene.I._UILayer.m_pCamera.ScreenToWorldPoint(Input.mousePosition);
                if (st.y >= 0.75f)
                {
                    return;
                }
                StartCoroutine("Cor_On");
                transform.position = st;
                OnPress2(true);
            }
        }
        if (mPressed == true)
        {
            OnDrag(Vector2.zero);
        }
        if (Input.GetMouseButtonUp(0))
        {
            m_eDirect = E_CSDIRECT.E_CENTER;
            StartCoroutine("Cor_Off");
            OnPress2(false);
        }

        /*if (!enumeratedJoysticks) {
         *      // Collect all joysticks in the game, so we can relay finger latching messages
         *      joysticks = FindObjectsOfType(typeof(UIJoystick)) as UIJoystick[];
         *
         *      enumeratedJoysticks = true;
         * }*/
    }
Example #8
0
    public void Create(E_CSDIRECT eDirect)
    {
        if (Create() == false)
        {
            return;
        }
        m_stPos   = Vector3.zero;
        m_stPos.y = -160.0f;
        m_stPos.x = 285.0f;

        if (eDirect == E_CSDIRECT.E_LEFT)
        {
            m_stPos.x *= -1.0f;
        }
        else
        {
            m_pCow.transform.localScale = new Vector3(-0.8f, 0.8f, 1.0f);
        }
    }
Example #9
0
    override public void HitPlayer()
    {
        if (m_bLife == false)
        {
            return;
        }
        JHGame_MainLayer.I.m_pEffect_Mng.CreateEffect_PT_MagicPoof(m_stPos);
        m_bLife           = false;
        m_eDieDirect      = E_CSDIRECT.E_RIGHT;
        m_fRotationSpeed *= -1.0f;
        if (JHGame_MainLayer.I._Hero.pSrc._Position.x >= m_stPos.x)
        {
            m_eDieDirect      = E_CSDIRECT.E_LEFT;
            m_fDieMoveX      *= -1.0f;
            m_fRotationSpeed *= -1.0f;
        }



        CSSoundMng.I.Play("Hit" + CSRandom.Rand(1, 4).ToString());
    }
Example #10
0
    override public bool Create()
    {
        if (base.Create() == false)
        {
            return(false);
        }
        m_eState  = E_HEROSTATE.E_MAX;
        m_eDirect = E_CSDIRECT.E_LEFT;

        m_stPos = new Vector3(0.0f, m_fGroundY, 0.0f);

        m_stJump.m_fDt      = 0.0f;
        m_stJump.m_fJumpDt  = 0.0f;
        m_stJump.m_eState   = E_JUMPSTATE.E_JUMP_NONE;
        m_stJump.m_fGravity = 90.8f;

        m_bMove = false;

        m_fSpeed          = JHGameData_Mng.I.m_pData_Stat._Basic_Speed;
        m_stJump.m_fPower = JHGameData_Mng.I.m_pData_Stat._Basic_JumpPower;

        m_fSpeed          += JHGameData_Mng.I.m_pData_Stat._Stat_Speed * JHGameData_Mng.I.m_pData_Stat._Factor_Speed;
        m_stJump.m_fPower += JHGameData_Mng.I.m_pData_Stat._Stat_JumpPower * JHGameData_Mng.I.m_pData_Stat._Factor_JumpPower;


        m_fMaxHp = JHGameData_Mng.I.m_pData_Stat._Basic_Hp;

        m_fMaxHp += JHGameData_Mng.I.m_pData_Stat._Stat_Hp * JHGameData_Mng.I.m_pData_Stat._Factor_Hp;

        m_fCurrHp = m_fMaxHp;


        m_fMaxPower  = 100.0f;
        m_fCurrPower = 0.0f;

        StartCoroutine(Cor_State_Start());
        ResetTransform();
        return(true);
    }
Example #11
0
    IEnumerator Cor_TutorialMove()
    {
        m_eDirect = E_CSDIRECT.E_RIGHT;
        m_pSprite.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
        if (m_stPos.x > 0.0f)
        {
            m_eDirect = E_CSDIRECT.E_LEFT;
            m_pSprite.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        }

        while (true)
        {
            if (m_eDirect == E_CSDIRECT.E_LEFT)
            {
                m_stPos.x -= m_fSpeed * Time.deltaTime;
                if (m_stPos.x <= -m_fWallX)
                {
                    m_stPos.x = -m_fWallX;
                }
            }
            else if (m_eDirect == E_CSDIRECT.E_RIGHT)
            {
                m_stPos.x += m_fSpeed * Time.deltaTime;
                if (m_stPos.x >= m_fWallX)
                {
                    m_stPos.x = m_fWallX;
                }
            }
            if (Mathf.Abs(m_stPos.x - 0.0f) < 30.0f)
            {
                ChangeState(E_HEROSTATE.E_NONE);
                break;
            }
            yield return(null);
        }

        yield return(null);
    }
Example #12
0
    override public void HitPlayer()
    {
        if (m_bLife == false)
        {
            return;
        }
        // CSDirector.I.GetDeviceDebug().Log("AAAA");
        JHGame_MainLayer.I.m_pEffect_Mng.CreateEffect_PT_MagicPoof(m_stPos);
        m_bLife           = false;
        m_eDieDirect      = E_CSDIRECT.E_RIGHT;
        m_fRotationSpeed *= -1.0f;
        if (JHGame_MainLayer.I._Hero.pSrc._Position.x >= m_stPos.x)
        {
            m_eDieDirect      = E_CSDIRECT.E_LEFT;
            m_fDieMoveX      *= -1.0f;
            m_fRotationSpeed *= -1.0f;
        }
        m_stJump.m_fPower   = 22.0f;
        m_stJump.m_fGravity = 90.9f;
        StartCoroutine("Cor_Jump");
        StartCoroutine("Cor_Banjjack");

        CSSoundMng.I.Play("Hit" + CSRandom.Rand(1, 4).ToString());
    }
Example #13
0
    void TouchMoveUpdate()
    {
        if (m_eState == E_HEROSTATE.E_STURN)
        {
            return;
        }
        if (m_eState == E_HEROSTATE.E_START)
        {
            return;
        }
        if (m_eState == E_HEROSTATE.E_DIE)
        {
            return;
        }

        if (JHGameData_Mng.I._GSencer == true)
        {
            //GSensor();
            Joypad();
            return;
        }

        //  if (Input.touchCount >=2 ||
        //      (Input.GetKey(KeyCode.LeftArrow) == true && Input.GetKey(KeyCode.RightArrow) == true))
        //  {
        //      ChangeState(E_HEROSTATE.E_NONE);
        //  }
        if (Input.touchCount == 1 ||
            (Input.anyKey == true))
        {
            Vector3 pTouchPos = Vector3.zero;


            //if(Input.touchCount==1) pTouchPos = JHGame_Scene.I._GameLayer.m_pCamera.ScreenToWorldPoint(Input.GetTouch(0).position);
            if (Input.touchCount >= 1)
            {
                pTouchPos = JHGame_Scene.I._GameLayer.m_pCamera.ScreenToWorldPoint(Input.touches[Input.touchCount - 1].position);
            }

            if (pTouchPos.y >= 0.75f)
            {
                return;
            }
            if ((pTouchPos.y >= -0.45f) || Input.GetKey(KeyCode.UpArrow))
            {
                ChangeState(E_HEROSTATE.E_JUMP);
            }

            /*  if ((Input.touchCount == 1 && Mathf.Abs(pTouchPos.x-transform.position.x)<0.08f) )
             * {
             *    ChangeState(E_HEROSTATE.E_NONE);
             *    return;
             * }*/

            // if ((Input.touchCount==1 && pTouchPos.x < 0.0f) || Input.GetKey(KeyCode.LeftArrow) == true)
            if ((pTouchPos.x < 0.0f) || Input.GetKey(KeyCode.LeftArrow) == true)
            {
                m_eDirect = E_CSDIRECT.E_LEFT;
                //   m_pSprite.transform.localPosition = new Vector3(-15.0f, 0.0f, 0.0f);
                m_pSprite.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
            }
            //  else if((Input.touchCount==1 && pTouchPos.x>=0.0f) || Input.GetKey(KeyCode.RightArrow) == true)
            else if ((pTouchPos.x >= 0.0f) || Input.GetKey(KeyCode.RightArrow) == true)
            {
                m_eDirect = E_CSDIRECT.E_RIGHT;
                // m_pSprite.transform.localPosition = new Vector3(15.0f, 0.0f, 0.0f);
                m_pSprite.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
            }
            m_bMove = true;
        }
        else if (Input.touchCount == 0)
        {
            m_bMove = false;
            if (m_stJump.m_eState == E_JUMPSTATE.E_JUMP_NONE)
            {
                ChangeState(E_HEROSTATE.E_NONE);
            }
        }

        if (m_bMove == true || m_stJump.m_eState != E_JUMPSTATE.E_JUMP_NONE)
        {
            if (m_eDirect == E_CSDIRECT.E_LEFT)
            {
                m_stPos.x -= m_fSpeed * Time.deltaTime;
                if (m_stPos.x <= -m_fWallX)
                {
                    m_stPos.x = -m_fWallX;
                }
            }
            else if (m_eDirect == E_CSDIRECT.E_RIGHT)
            {
                m_stPos.x += m_fSpeed * Time.deltaTime;
                if (m_stPos.x >= m_fWallX)
                {
                    m_stPos.x = m_fWallX;
                }
            }
            ChangeState(E_HEROSTATE.E_MOVE);
        }
    }
Example #14
0
    /// <summary>
    /// Drag the object along the plane.
    /// </summary>

    void OnDrag(Vector2 delta)
    {
        //Debug.Log("delta " +  delta + " delta.magnitude = " + delta.magnitude);

        //	Ray ray = UICamera.currentCamera.ScreenPointToRay(UICamera.lastTouchPosition);
        Ray   ray  = UICamera.currentCamera.ScreenPointToRay(UICamera.GetTouch(0).pos);
        float dist = 0f;

        Vector3 currentPos = ray.GetPoint(dist);
        Vector3 offset     = currentPos - userInitTouchPos;

        if (offset.x != 0f || offset.y != 0f)
        {
            offset = target.InverseTransformDirection(offset);
            offset.Scale(scale);
            offset = target.TransformDirection(offset);

            offset.y = 0.0f;
            offset.z = 0f;
        }
        if (offset.x > 0.0f)
        {
            m_eDirect = E_CSDIRECT.E_RIGHT;
        }
        else if (offset.x < 0.0f)
        {
            m_eDirect = E_CSDIRECT.E_LEFT;
        }
        else
        {
            m_eDirect = E_CSDIRECT.E_CENTER;
        }


        target.position = userInitTouchPos + offset;

        Vector3 zeroZpos = target.position;

        zeroZpos.z      = 0f;
        target.position = zeroZpos;
        // Calculate the length. This involves a squareroot operation,
        // so it's slightly expensive. We re-use this length for multiple
        // things below to avoid doing the square-root more than one.

        float length = target.localPosition.magnitude;

        if (length < deadZone)
        {
            // If the length of the vector is smaller than the deadZone radius,
            // set the position to the origin.
            position             = Vector2.zero;
            target.localPosition = position;
        }
        else if (length > radius)
        {
            target.localPosition = Vector3.ClampMagnitude(target.localPosition, radius);
            position             = target.localPosition;
        }


        if (normalize)
        {
            // Normalize the vector and multiply it with the length adjusted
            // to compensate for the deadZone radius.
            // This prevents the position from snapping from zero to the deadZone radius.
            position = position / radius * Mathf.InverseLerp(radius, deadZone, 1);
        }
    }