コード例 #1
0
    void Power()
    {
        powered = true;
        ++poweredCount;
        Debug.Log("Powered " + poweredCount + " / " + stars.Count);

        if (halo != null)
        {
            halo.SetON(true);
        }

        SoundLevel1.Instance.HitStar(gameObject);         //michèle
    }
コード例 #2
0
ファイル: SwappableStar.cs プロジェクト: Yakka/Aku
    void OnTriggerEnter(Collider other)
    {
        if (!swapping)
        {
            DrakeScale drakeScale = other.GetComponent <DrakeScale>();
            if (drakeScale != null && drakeScale.HasMoonPaint)
            {
                Drake drake = drakeScale.drakeRef;

                if (drake.LastTouchedStar == null)
                {
                    // First star selected !
                    if (halo != null)
                    {
                        halo.SetON(true);
                    }
                    drake.LastTouchedStar = gameObject;
                }
                else
                {
                    SwappableStar otherStar =
                        drake.LastTouchedStar.GetComponent <SwappableStar>();

                    // If the star exist and is different
                    if (otherStar != null && otherStar != this)
                    {
                        drake.LastTouchedStar = null;

                        // Second star selected, swapping !
                        Swap(otherStar, true);
                        SoundLevel2.Instance.SwapStar();
                    }
                }
            }
        }
    }
コード例 #3
0
ファイル: Ladybird.cs プロジェクト: Yakka/Aku
    // Update is called once per frame
    void Update()
    {
        if (targets == null || initialPositions == null)
        {
            return;
        }

        if (halo != null && Time.time >= haloTimer && isHaloing)
        {
            isHaloing = false;
            halo.SetON(false);
        }

        switch (state)
        {
        case STATE_SLEEPING:
            for (int i = 0; i < initialPositions.Length; i++)
            {
                if (initialPositions[i].IsActivated())
                {
                    state = STATE_WAITING;
                    transform.position = initialPositions[i].transform.position;
                    renderer.enabled   = true;
                }
            }
            break;

        case STATE_MOVING:
            Vector3 target           = targets[index].transform.position;
            float   distanceToTarget = Vector2.Distance(target, transform.position);

            // If I'm not on my current target
            if (distanceToTarget > 0.1f)
            {
                MoveTo(target);
            }
            else
            {
                state      = STATE_WAITING;
                nextSearch = Time.time + MAX_WAITING;
                CommonSounds.Instance.LadybirdStoping();
                animation.Play("land");
            }

            break;

        case STATE_WAITING:
            if (triggered)
            {
                nextSearch = Time.time + MAX_WAITING;
                Disturb();
            }

            else if (Time.time > nextSearch)
            {
                state = STATE_SEARCHING;
                animation.Play("takeOff");
                CommonSounds.Instance.LadybirdMoving();
            }
            else if (!animation.isPlaying)
            {
                if (Random.Range(0f, 1f) < 0.05f)
                {
                    animation.Play("stand");
                }
            }

            break;

        case STATE_SEARCHING:
            Vector3 drakePosition   = drake.position;
            float   distanceToDrake = Vector2.Distance(drakePosition, transform.position);
            // If I'm not on my current target
            if (distanceToDrake > 20f)
            {
                MoveTo(drakePosition);
            }
            else
            {
                CommonSounds.Instance.LadybirdCall();
                if (halo != null)
                {
                    halo.SetON(true);
                    haloTimer = Time.time + HALO_TIME;
                    isHaloing = true;
                }
                state = STATE_MOVING;
            }
            break;

        case STATE_JOY:
            transform.rotation =
                Quaternion.Lerp(
                    transform.rotation,
                    Quaternion.Euler(0f, 0f, 360) * originalRotation,
                    ANGULAR_LERP_COEF);
            if (!animation.isPlaying)            // Play the animation
            {
                animation.Play("fly");
            }
            break;

        case STATE_GRABBED:
            float distanceToPrison = Vector2.Distance(prison.position, transform.position);

            // If I'm not on my current target
            if (distanceToPrison > 0.1f)
            {
                MoveTo(prison.position);
            }
            else
            {
                Helper.SetActive(gameObject, false);
            }
            break;
        }
    }