コード例 #1
0
ファイル: PlayerScript.cs プロジェクト: edwonedwon/Not-Alone
    public void OnPlayerFingerDown(int finger, Vector2 pos)
    {
        PlayOneShotAudio(currentPlaySndIdx);
        if (++currentPlaySndIdx > 2)
        {
            currentPlaySndIdx = 0;
        }



        currentMousePoints.Add(pos);
        currentMovements.CalculateMovementBounds(pos);
        currentMovements.CalculateCurrentQuadrant(this, pos, currentMousePoints);

        transform.position = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, zOffset));
        GameObject.Instantiate(RippleObjectPrefab, transform.position, Quaternion.identity);

        mouseIsMovingWhileDown = true;

        currentMovements.NumTouchDowns         += 1;
        currentMovements.TimeSinceLastTouchDown = 0.0f;

        //game-mode: tapping in same spot calling out plankton
        if (currentFingerState != (FingerState)finger)
        {
            Vector2 v2D = transform.position;

            currentFingerState = (FingerState)finger;
            if (currentFingerState == FingerState.Single)
            {
                //current semi-hack to place pinched-prefab object. must also be handled in the OnPinchEnd()
                if (PinchCreateObjectPrefab != null)
                {
                    //Network.Instantiate(PinchCreateObjectPrefab, v2D, Quaternion.identity, 0);
                }

                Vector2 diff = lastMouseDownPos - pos;

                if (diff.magnitude < 30.0f)
                {
                    if (++numberOfTapsInSameSpot > 1)
                    {
                        //if(UnityEngine.Random.Range (0, 100) > 25.0f)
                        fluidField.IncreaseSpiritParticles(1, isPlayer1 ? 0 : 1);
                        numberOfTapsInSameSpot = 0;
                    }
                }
                //else
                {
                    //	numberOfTapsInSameSpot = 0;
                }

                //DebugStreamer.message = "numberOfTapsInSameSpot: " + numberOfTapsInSameSpot.ToString();
            }
        }

        lastMouseDownPos = pos;
    }