Example #1
0
 private void OnAttachBalloon(Balloon pBalloon, GameObject pTack)
 {
     GameObject balloonObject = pBalloon.GameObject;
     Rope rope = balloonObject.transform.GetChild(0).GetComponent<Rope>();
     Rigidbody2D tackBody = pTack.GetComponent<Rigidbody2D> ();
     AttachRopeToCharacter (balloonObject, rope, tackBody);
 }
Example #2
0
 public void OnTriggerBalloon(Balloon pBalloon)
 {
     if (pBalloon != null && pBalloon.GameObject == mBalloon.GameObject)
     {
         mBalloon.Physics.PopBalloon();
     }
 }
Example #3
0
 protected override void AttachBalloon(Balloon pBalloon)
 {
     base.AttachBalloon (pBalloon);
     if (pBalloon.Type == EBalloonType.FLYING) {
         mIsFlying = true;
     }
 }
Example #4
0
	void Start ()
    {
        _instance = this;
        //StartCoroutine(AnimationCore());
        var uiSprite = GetComponent<UISprite>();
        uiSprite.alpha = 0.0f;
	}
Example #5
0
    //Simple collision detection
    void OnTriggerEnter(Collider c)
    {
        if (c.collider.gameObject.layer == 9)
        {
            hitObject = c.collider.gameObject.GetComponent<Balloon>();
            GameObject particleProv = (GameObject)GameObject.Instantiate(particle);
            particleProv.transform.position = hitObject.transform.position;

            if (hitObject.Idballoon == "red")
            {
                particleProv.renderer.material.mainTexture = particleTexture[0];
            }
            if (hitObject.Idballoon == "blue")
            {
                particleProv.renderer.material.mainTexture = particleTexture[1];
            }
            if (hitObject.Idballoon == "green")
            {
                particleProv.renderer.material.mainTexture = particleTexture[2];
            }
            if (hitObject.Idballoon == "yellow")
            {
                particleProv.renderer.material.mainTexture = particleTexture[3];
            }
            if (menuScript.survivorMode)
            {
                menuScript.scoreScript.SurvivorDestroyed();
            }
            soundScript.PlaySound(33, false, 0.5f);
            Destroy(hitObject.gameObject);
        }
    }
Example #6
0
 public override void DetachBalloon(Balloon pBalloonToDetach)
 {
     base.DetachBalloon (pBalloonToDetach);
     if (pBalloonToDetach.Type == EBalloonType.FLYING) {
         mIsFlying = false;
     }
 }
Example #7
0
        void INumberState.Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            defaultMoveTweener.Update(gameTime);
            Owner.Y = (int)defaultMoveTweener.Position;

            //TODO: Maybe dirty, should use OnHandCollide somehow, because I query the colliding hand two times, once in number and then here
            var hand = (PlayerHand)Owner.GetFirstCollidingEntity("hand");

            if (hand != null && (hand.Player == Owner.Owner || Owner.Owner == null) && hand.DraggingBalloon == null) {
                if (Configuration.GRABBING_ENABLED) {
                    if (hand.IsGrabbing) {
                        var balloon = new Balloon(hand.X, hand.Y, Owner.Number);
                        hand.Screen.AddEntity(balloon);

                        hand.Grab(balloon);
                    }
                } else {
                    hoverTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
            } else {
                hoverTime = 0;
            }

            if (hoverTime > maxHoverTime) {
                var balloon = new Balloon(hand.X, hand.Y, Owner.Number);
                hand.Screen.AddEntity(balloon);

                hand.Grab(balloon);
            }
        }
Example #8
0
 public virtual void DestroyBalloon(Balloon pBalloon)
 {
     DetachBalloon(pBalloon);
     Destroy(pBalloon.gameObject);
     Destroy(pBalloon.Physics);
     EventService.DispatchEvent (EGameEvent.DROP_BALLOON, pBalloon);
 }
Example #9
0
 void Update()
 {
     //if pause is on, we cannot drag them
     if (!menuScript.pause)
     {
         //we use raycast to catch the drag collider
         if (Input.GetMouseButtonDown(0))
         {
             Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
             if (Physics.Raycast(ray, out hit))
             {
                 if (hit.collider.gameObject.layer == 8)
                 {
                     objectGo = hit.collider.gameObject;
                     onDrag = true;
                 }
             }
         }
         //If we clicked or touched now the balloon position belongs to our cursor o finger position
         if (onDrag)
         {
             posMouse = Camera.mainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.mainCamera.nearClipPlane + 30));
             if (objectGo != null)
             {
                 ballonScript = objectGo.transform.root.gameObject.GetComponent<Balloon>();
                 if (ballonScript.Idballoon == "red" || ballonScript.Idballoon == "green" || ballonScript.Idballoon == "blue" || ballonScript.Idballoon == "yellow")
                 {
                     faceManager = objectGo.transform.root.GetComponentInChildren<FaceManager>();
                 }
                 if (faceManager != null)
                 {
                     faceManager.gameObject.renderer.material.mainTexture = faceManager.facesList[1];
                 }
                 objectGo.transform.position = posMouse;
             }
             else
             {
                 onDrag = false;
             }
         }
         //
         //If we stop dragging now the balloon has his own position
         if (Input.GetMouseButtonUp(0))
         {
             onDrag = false;
             if (objectGo != null)
             {
                 ballonScript = objectGo.transform.root.gameObject.GetComponent<Balloon>();
                 ballonScript.aceleration = -1;
                 if (ballonScript.Idballoon == "red" || ballonScript.Idballoon == "green" || ballonScript.Idballoon == "blue" || ballonScript.Idballoon == "yellow")
                 {
                     randomFace = Random.Range(0, 11);
                     faceManager.gameObject.renderer.material.mainTexture = faceManager.facesList[randomFace];
                 }
                 objectGo = null;
             }
         }
         //
     }
 }
Example #10
0
 // Update is called once per frame
 void Update()
 {
     //we use OverlapSphere to manage a radius and wich elements are we going to catch
     arrayList = Physics.OverlapSphere(this.transform.position, 3, headMask);
     //For every balloon near the Refresher, we change the color
     for (int i = 0; i < arrayList.Length; i++)
     {
         ballon = arrayList[i].GetComponent<Balloon>();
         if (ballon.Idballoon == "red" || ballon.Idballoon == "yellow" || ballon.Idballoon == "blue" || ballon.Idballoon == "green")
         {
             if (selectColor == 0)
             {
                 ballon.renderer.material.mainTexture = ballonTxt[0];
                 ballon.Idballoon = "red";
             }
             if (selectColor == 1)
             {
                 ballon.renderer.material.mainTexture = ballonTxt[1];
                 ballon.Idballoon = "blue";
             }
             if (selectColor == 2)
             {
                 ballon.renderer.material.mainTexture = ballonTxt[2];
                 ballon.Idballoon = "green";
             }
             if (selectColor == 3)
             {
                 ballon.renderer.material.mainTexture = ballonTxt[3];
                 ballon.Idballoon = "yellow";
             }
         }
     }
     //
 }
Example #11
0
 private void OnDropBalloon(Balloon pBalloon)
 {
     if (pBalloon.GameObject == mBalloon.GameObject && !pBalloon.Physics.IsAttached) {
         Vector2 position = transform.position;
         EventService.DispatchEvent(EGameEvent.ATTEMPT_ATTACH_BALLOON, pBalloon, position);
     }
 }
Example #12
0
 public override void DestroyBalloon(Balloon pBalloon)
 {
     base.DestroyBalloon (pBalloon);
     if (GetLifeBalloonCount() <= 0)
     {
         EventService.DispatchEvent(EGameEvent.GAME_OVER);
     }
 }
Example #13
0
 public override void DetachBalloon(Balloon pBalloonToDetach)
 {
     if (pBalloonToDetach.Type.Equals (EBalloonType.LIFE)) {
         mNumberOfLifeBalloons--;
     } else {
         mNumberOfSpecialBalloons--;
     }
     base.DetachBalloon (pBalloonToDetach);
 }
Example #14
0
 public void OnTriggerBalloon(Balloon pBalloon)
 {
     if (pBalloon != null && pBalloon.GameObject == mBalloon.GameObject)
     {
         mIsDeflating = true;
         PreventAttaching();
         //Start emission of "spray" particles
     }
 }
Example #15
0
 private void DropBalloon()
 {
     if (mTouchedBalloonObject != null && mTouchedBalloon != null)
     {
         EventService.DispatchEvent(EGameEvent.DROP_BALLOON, mTouchedBalloon);
         mTouchedBalloonObject = null;
         mTouchedBalloonPhysics = null;
         mTouchedBalloon = null;
         mIsJumpCommand = false;
     }
 }
Example #16
0
 private void OnAttachBalloon(Balloon pBalloon, GameObject pTack)
 {
     if (((Balloon)pBalloon).GameObject == mBalloon.GameObject) {
         MoveableObject flyingObject = mBalloon.BalloonHolder.Owner.GetComponent<MoveableObject>();
         if(flyingObject != null)
         {
             mIsAttachedToMoveableObject = true;
             AllowFlight (flyingObject);
             DisallowDetach();
         }
     }
 }
Example #17
0
        public void TestRespondToInteraction()
        {
            Position position = new Position(23, 34);

            GameObject balloon = new Balloon(position, '2', Colour.Green);

            balloon.RespondToInteraction();

            bool actual = balloon.IsDestroyed;
            bool expected = true;

            Assert.AreEqual(expected, actual);
        }
Example #18
0
        public void TestUpdatePosition()
        {
            Position position = new Position(17, 42);

            GameObject balloon = new Balloon(position, '1', Colour.Red);

            Position vectorChange = new Position(20, -3);

            balloon.UpdatePosition(vectorChange);

            Position actual = balloon.Position;
            Position expected = new Position(37, 39);

            Assert.AreEqual(expected, actual);
        }
Example #19
0
        void INumberState.Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            defaultMoveTweener.Update(gameTime);
            Owner.Y = (int)defaultMoveTweener.Position;

            //TODO: Maybe dirty, should use OnHandCollide somehow, because I query the colliding hand two times, once in number and then here
            var hand = (PlayerHand)Owner.GetFirstCollidingEntity("hand");

            // nicht so ganz sicher warum/ob das funktioniert
            //if (hand != null && (hand.Player == Owner.Owner || Owner.Owner == null) && hand.DraggingBalloon == null && hand.Pressing) {
            if (hand != null  && hand.DraggingBalloon == null && hand.Pressing) {
                var balloon = new Balloon((int)hand.X, (int)hand.Y, Owner.Number);
                hand.Screen.AddEntity(balloon);
                hand.Grab(balloon);
            }
        }
Example #20
0
        public BalloonDeathEmitter(Balloon balloon)
            : base(balloon.GetCenter().X + 25, balloon.GetCenter().Y + 25, balloon.z - 0.1f)
        {
            this.particleScale = 2f;
            this.particlesPerTick = 25;
            this.lifespanMS = 900;
            this.ticksPerSecond = 1;

            this.particleSpeedX = -2f;
            this.particleSpeedY = -1.33f;

            this.particleRandomSpeedX = 4f;
            this.particleRandomSpeedY = 6f;

            this.particleLifespanMS = 500;

            this.fadeAccordingToLifespan = true;

            this.particleGravity = 0.75f;
            this.particleScale = 0.15f;

            switch (balloon.color)
            {
                case Balloon.BalloonColor.Black:
                    this.particleTexture = BALLOON_DEATH_PARTICLE_BLACK;
                    break;
                case Balloon.BalloonColor.Blue:
                    this.particleTexture = BALLOON_DEATH_PARTICLE_BLUE;
                    break;
                case Balloon.BalloonColor.Yellow:
                    this.particleTexture = BALLOON_DEATH_PARTICLE_YELLOW;
                    break;
                case Balloon.BalloonColor.Pink:
                    this.particleTexture = BALLOON_DEATH_PARTICLE_PINK;
                    break;
            }

            this.balloon = balloon;

            this.blendState = BlendState.AlphaBlend;
        }
Example #21
0
 public virtual void DetachBalloon(Balloon pBalloonToDetach)
 {
     mBalloons.Remove (pBalloonToDetach);
 }
Example #22
0
 private void OnBalloonGiven(Balloon pBalloon)
 {
     AddGreyScale(mStepValue);
 }
Example #23
0
 private void SetBalloonProperties(Balloon pBalloon, BalloonPhysics pPhysic, int pBalloonIndex)
 {
     pBalloon.SetBalloonHolder(this);
     pBalloon.SetBalloonIndex (pBalloonIndex);
     pPhysic.SetTack(m_Tack);
 }
Example #24
0
 protected virtual void AttachBalloon(Balloon pBalloon)
 {
     pBalloon.SetBalloonIndex (CountBalloons ());
     pBalloon.SetBalloonHolder (this);
     mBalloons.Add (pBalloon);
     pBalloon.GameObject.transform.parent = this.gameObject.transform;
     EventService.DispatchEvent(EGameEvent.ATTACH_BALLOON, pBalloon, m_Tack);
     pBalloon.Physics.IgnoreOtherBalloonCollision();
 }
Example #25
0
 public void OnAttemptAttachBalloon(Balloon pBalloon, Vector2 pPosition)
 {
     if (CountBalloons () < m_MaxBalloonCount) {
         Collider2D[] touchedColliders = Physics2D.OverlapCircleAll (pPosition,  1f);
         Collider2D thisCollider = m_Tack.transform.parent.GetComponent<Collider2D> ();
         for(int i = 0; i < touchedColliders.Length; i++)
         {
             if(touchedColliders[i] == thisCollider && !pBalloon.Physics.IsAttached)
             {
                 pBalloon.Physics.DetachBalloon();
                 AttachBalloon (pBalloon);
                 break;
             }
         }
     }
 }
Example #26
0
 void Start()
 {
     mBalloon = GetComponent<Balloon>();
     mRigidbody2D = GetComponent<Rigidbody2D>();
     mLineRenderer = GetComponent<LineRenderer>();
     mBalloonJoint = GetComponent<HingeJoint2D>();
     mDistanceJoint = GetComponent<DistanceJoint2D>();
     mCircleCollider = GetComponent<CircleCollider2D>();
     mRope = GetComponentInChildren<Rope>();
     m_Parent = mBalloonHolder.transform;
     //EventListener.Register(EGameEvent.HAZARDOUS_COLLISION, OnHazardousCollision);
     mainCharacter = mTack.transform.parent;
     Physics2D.IgnoreCollision(mainCharacter.GetComponent<BoxCollider2D>(), mCircleCollider);
     EventService.Register<BalloonDelegate>(EGameEvent.PICKUP_BALLOON, OnPickupBalloon);
     EventService.Register<BalloonDelegate>(EGameEvent.DROP_BALLOON, OnDropBalloon);
     EventService.Register<AttachBalloonDelegate>(EGameEvent.ATTACH_BALLOON, OnAttachBalloon);
 }
Example #27
0
 public void OnPickupBalloon(Balloon pBalloon)
 {
     if (mBalloon == pBalloon)
     {
         mIsTouched = true;
         IgnoreOtherBalloonCollision();
         mRigidbody2D.gravityScale = 0;
         mRigidbody2D.drag = 0;
     }
 }
Example #28
0
 public void OnDropBalloon(Balloon pBalloon)
 {
     if (pBalloon == mBalloon)
     {
         mIsTouched = false;
         mRigidbody2D.drag = 1;
         mRigidbody2D.gravityScale = mBalloon.GravityScale;
         StopIgnoringOtherBalloonCollision();
         EventService.DispatchEvent(EGameEvent.END_PULLING);
     }
 }
Example #29
0
 public void OnAttachBalloon(Balloon pBalloon, GameObject pTack)
 {
     if(pBalloon == mBalloon)
     {
         mDistanceJoint.enabled = true;
         mBalloonJoint.enabled = true;
         mLineRenderer.enabled = true;
         mIsAttached = true;
         mTack = pTack;
     }
 }
 public void Respawn(Balloon balloon)
 {
     AudioManager.Instance.PlaySpawnObject();
     balloon.transform.position = this.NewPosition(balloon is LightbulbBalloon);
     balloon.gameObject.SetActive(true);
 }