Esempio n. 1
0
    void Start()
    {
        // The tiles
        tilePos[0] = IcePath_GenerateMap.wakaStart[_wakaIndex];
        tilePos[1] = IcePath_GenerateMap.wakaEnd[_wakaIndex];

        transform.position = tilePos[1];

        // Animator
        animator = transform.Find("Rig").Find("Animation").GetComponent <Animator>();

        leapAlarm = leapTime;

        if (splashInstance == null)
        {
            splashInstance = this;
        }
    }
Esempio n. 2
0
    void Update()
    {
        // Is this the ice cream?
        if (_tile[cirnoGridX, cirnoGridY] == "B" &&
            MathHelper.Approximately(transform.position.x, cirnoEndPos.x, .01f) &&
            MathHelper.Approximately(transform.position.y, cirnoEndPos.y, .01f))
        {
            if (!hasWon)
            {
                Win();
                hasWon        = true;
                tiltDirection = 0f;
            }
        }

        // Update angle
        currentAngle          = Mathf.MoveTowards(currentAngle, getTiltAngleGoal(), tiltSpeed * Time.deltaTime);
        tiltPivot.eulerAngles = Vector3.forward * currentAngle;

        // Is this a Waka passing?
        int wakaIndex;

        if (int.TryParse(_tile[cirnoGridX, cirnoGridY], out wakaIndex))
        {
            // Is Waka passing through?
            GameObject   waka       = IcePath_GenerateMap.wakaObject[wakaIndex];
            IcePath_Waka wakaScript = waka.GetComponent <IcePath_Waka>();

            if (!wakaScript.isPassable)
            {
                if (!isHit)
                {
                    // Get hit

                    Die();
                    isHit = true;

                    MicrogameController.instance.playSFX(hitSound, volume: 0.75f,
                                                         panStereo: AudioHelper.getAudioPan(transform.position.x));

                    MicrogameController.instance.setVictory(victory: false, final: true);
                }
            }
        }

        // Has Cirno been hit?
        if (isHit)
        {
            // Lose condition - fly away now
            transform.position = transform.position + (new Vector3(-8, 8, 0) * Time.deltaTime);
            transform.Find("Spin Pivot").Find("Rig").Rotate(new Vector3(0, 0, 270 * Time.deltaTime));
        }
        else

        // Has Cirno won?
        if (hasWon)
        {
            /* oh. she has? alright */
        }
        else

        // Move on as usual
        {
            // Move Cirno towards grid if applicable
            MathHelper.moveTowards2D(transform, cirnoEndPos, moveSpeed);

            // Movement
            int moveX = (Input.GetKeyDown(KeyCode.RightArrow) ? 1 : 0) - (Input.GetKeyDown(KeyCode.LeftArrow) ? 1 : 0);
            int moveY = (Input.GetKeyDown(KeyCode.UpArrow) ? 1 : 0) - (Input.GetKeyDown(KeyCode.DownArrow) ? 1 : 0);

            if (moveX != 0)
            {
                moveY = 0;
            }
            else
            {
                moveX = 0;
            }

            // Player is moving
            if (moveX != 0 ||
                moveY != 0)
            {
                // Valid movement?
                if (canWalkInto(cirnoGridX + moveX, cirnoGridY - moveY))
                {
                    cirnoGridX += moveX;
                    cirnoGridY -= moveY;

                    transform.position = cirnoEndPos;   //Snap to next block
                    cirnoEndPos        = mapPos(cirnoGridX, -cirnoGridY);

                    MicrogameController.instance.playSFX(moveClip,
                                                         pitchMult: Random.Range(.96f, 1.04f),
                                                         panStereo: AudioHelper.getAudioPan(transform.position.x),
                                                         volume: .5f);
                    tiltDirection = tiltDirection == 0f ? -1f : -tiltDirection;
                    if (moveX != 0 && (float)moveX != Mathf.Sign(tiltPivot.localScale.x))
                    {
                        tiltPivot.localScale = new Vector3(-tiltPivot.localScale.x, tiltPivot.localScale.y, tiltPivot.localScale.z);
                    }
                }
            }
        }
    }
Esempio n. 3
0
 private void Awake()
 {
     splashInstance = null;
 }