Exemple #1
0
    void Start()
    {
        int  maxBuoys         = 5;      //max limit available
        bool tooCloseToOthers = SoundBuoyScript.CloseToOthers(gameObject, 100.0f);

        if (!tooCloseToOthers)
        {
            tooCloseToOthers = BlackHoleScript.CloseToOthers(gameObject, 100.0f);
        }

        if (WorldBuoysList.Count >= maxBuoys || tooCloseToOthers)
        {
            DestroyImmediate(gameObject);
            return;
        }


        buoyAnimations[0] = "appear";
        buoyAnimations[1] = "moving";
        buoyAnimations[2] = "drop";
        buoyAnimations[3] = "ringing";
        buoyAnimations[4] = "ding";
        buoyAnimations[5] = "sink";
        buoyAnimations[6] = "underwater";

        sprite.animationCompleteDelegate += AnimationComplete;

        WorldBuoysList.Add(this);
        fluidField = GameObject.FindGameObjectWithTag("fluidField").GetComponent <FluidFieldGenerator>();

        audio.clip   = ringingSounds[WorldBuoysList.IndexOf(this)];
        audio.loop   = true;
        audio.volume = 0.0f;
        audio.Play();
    }
    void Start()
    {
        int  maxBlackHoles    = 4;
        bool tooCloseToOthers = SoundBuoyScript.CloseToOthers(gameObject, 100.0f);

        if (!tooCloseToOthers)
        {
            tooCloseToOthers = BlackHoleScript.CloseToOthers(gameObject, 100.0f);
        }

        if (WorldBlackHoles.Count >= maxBlackHoles || tooCloseToOthers)
        {
            DestroyImmediate(gameObject);
            return;
        }

        WorldBlackHoles.Add(this);
    }
Exemple #3
0
    void FixedUpdate()
    {
        if (p1 == null)
        {
            p1 = GameObject.FindGameObjectWithTag("PLAYER1");
            if (p1 != null)
            {
                player1 = p1.GetComponent <PlayerScript>();
            }
        }
        if (p2 == null)
        {
            p2 = GameObject.FindGameObjectWithTag("PLAYER2");
            if (p2 != null)
            {
                player2 = p2.GetComponent <PlayerScript>();
            }
        }

        bool doInkLink     = false;
        bool riverComplete = SoundBuoyScript.CheckForRiverCompletion();

        if (p1 != null && p2 != null)
        {
            PlayerScript.FingerState p1finger = player1.MouseFingerDown();
            PlayerScript.FingerState p2finger = player2.MouseFingerDown();

            foreach (BlackHoleScript bh in BlackHoleScript.WorldBlackHoles)
            {
                if (Network.isServer)
                {
                    player1.UpdateAgainstBlackHole(bh);
                }
                else if (Network.isClient)
                {
                    player2.UpdateAgainstBlackHole(bh);
                }
            }


            bool canCreateRiverBetweenActivatedBuoys = false;
            int  buoysWithFingersDownActivated       = 0;

            //if(Network.isServer)
            {
                if (player1.DoLinkInk() && player1.DoLinkInk())
                {
                    SoundBuoyScript buoy1 = null;
                    SoundBuoyScript buoy2 = null;

                    float minDist = 160.0f;
                    float best1   = 9999.0f;
                    float best2   = 9999.0f;

                    Vector2 p1v = player1.transform.position;
                    Vector2 p2v = player2.transform.position;

                    foreach (SoundBuoyScript sbs in SoundBuoyScript.WorldBuoysList)
                    {
                        Vector2 sbspos = sbs.transform.position;
                        float   mag1   = (sbspos - p1v).magnitude;
                        float   mag2   = (sbspos - p2v).magnitude;

                        if (mag1 < minDist && mag1 < best1)
                        {
                            best1 = mag1;
                            buoy1 = sbs;
                        }
                        if (mag2 < minDist && mag2 < best2)
                        {
                            best2 = mag2;
                            buoy2 = sbs;
                        }
                    }

                    if (buoy1 != null && buoy2 != null)
                    {
                        if (buoy1 != buoy2)
                        {
                            buoy1.ActivatedWithOther = buoy2;
                            buoy2.ActivatedWithOther = buoy1;
                        }
                    }
                }
            }

            //Find out if they are touching...
            Vector3 v1 = p1.transform.position;
            Vector3 v2 = p2.transform.position;

            float difference = (v1 - v2).magnitude;

            if (difference < 50.0f)
            {
                if (p1finger == PlayerScript.FingerState.Single && p2finger == PlayerScript.FingerState.Single)
                {
                    timeTogetherNotMoving += Time.deltaTime;
                }
                if (timeTogetherNotMoving > 1.0f && !playTogetherAudio)
                {
                    playTogetherAudio = true;
                    audio.Play();
                }
                if (timeTogetherNotMoving > 5.0f)
                {
                    playTogetherAudio     = false;
                    timeTogetherNotMoving = -5;
                    ClearAllGameEntitiesOut();
                    //GameLogicController.instance.MoveToNextLevel();		//not anymore!
                }
            }
            else
            {
                if (playTogetherAudio)
                {
                    playTogetherAudio = false;
                    audio.Stop();
                }

                if (timeTogetherNotMoving >= 1.0f)
                {
                    player1.SetDoLinkInk(true);
                    player2.SetDoLinkInk(true);
                }
                timeTogetherNotMoving = 0.0f;
            }

            if (p1finger != PlayerScript.FingerState.Single || p2finger != PlayerScript.FingerState.Single)
            {
                timeTogetherNotMoving = 0;
                player1.SetDoLinkInk(false);
                player2.SetDoLinkInk(false);
            }
        }
    }