示例#1
0
    public bool OnPowerUpTrigger(IPowerUpTrigger pwrUpTrigger)
    {
        if (pwrUpTrigger.GetType() == typeof(PuckCollisionTrigger))
        {
            PuckCollisionTrigger puckCollTrigger = (PuckCollisionTrigger)pwrUpTrigger;
            Collision2D          coll            = puckCollTrigger.Coll;

            if (coll.gameObject.tag == "Peg" && pegBreakCount < maxPegBreaks)
            {
                Puck puck = puckCollTrigger.Puck;

                // Ignore collision with this peg
                Collider2D puckCollider = puck.gameObject.GetComponent <Collider2D>();
                Physics2D.IgnoreCollision(coll.collider, puckCollider);

                pegBreakCount++;
                //Peg peg = coll.gameObject.GetComponent<Peg>();
                //peg.Explode();

                UpdatePuckVelPerPegCount();

                StartCoroutine("StutterPuckMovement");

                if (pegBreakCount == maxPegBreaks)
                {
                    PowerUpExpiredPayload pwrUpExpiredPayload = new PowerUpExpiredPayload(this);
                    pwrUpExpiredEvent.Invoke(pwrUpExpiredPayload);
                    Destroy(this);
                }
            }
            return(true);
        }
        return(false);
    }
示例#2
0
文件: PegSmasher.cs 项目: coshm/SPFT
        /*private void DampenPuckMomentum(Peg peg, Puck puck) {
         *  Debug.Log($"Attempting to Dampen Puck Momentum after {pegBreakCount} broken Pegs.");
         *
         *  Rigidbody2D puckBody = puck.GetComponent<Rigidbody2D>();
         *
         *  Vector2 collisionNormal = puck.transform.position - peg.transform.position;
         *  collisionNormal.Normalize();
         *  Debug.Log($"Normal Vector={collisionNormal}");
         *
         *  Vector2 puckVelocity = puckBody.velocity;
         *  Debug.Log($"Current Puck Velocity={puckVelocity}");
         *
         *  Vector2 projVOnN = puckVelocity * (float) (Math.Abs(Vector2.Dot(puckVelocity, collisionNormal)) / Math.Pow(puckVelocity.magnitude, 2));
         *  Debug.Log($"Projection of Vel onto Normal={projVOnN}");
         *
         *  float pegBreakCountMod = (float) Math.Pow((double) pegBreakCount / maxPegBreaks, 2.0);
         *  Debug.Log($"pegBreakCountMod={pegBreakCountMod}");
         *
         *  Vector2 newPuckVelocity = puckVelocity + pegBreakCountMod * projVOnN;
         *  Debug.Log($"New Puck Velocity={newPuckVelocity}");
         *
         *  puckBody.velocity = newPuckVelocity;
         * }*/


        private void DampenPuckMomentum(Peg peg, Puck puck)
        {
            Debug.Log($"Attempting to Dampen Puck Momentum after {pegBreakCount} broken Pegs.");

            Rigidbody2D puckBody = puck.GetComponent <Rigidbody2D>();
            Vector2     v        = puckBody.velocity;

            Debug.Log($"Current Velocity of the Puck is: {v}");

            Vector2 n = puck.transform.position - peg.transform.position;

            n.Normalize();
            Debug.Log($"The normalized collision vector is {n}");

            float scalarProjVOnN = Vector2.Dot(n, v) / n.magnitude;

            Debug.Log($"The scalar projection of V onto N is {scalarProjVOnN}");

            Vector2 pegsForceOnPuck = scalarProjVOnN * n;

            Debug.Log($"The full force on the Puck from the Peg is: {pegsForceOnPuck}");

            float pegBreakCountMod = (float)Math.Pow((double)pegBreakCount / maxPegBreaks, 2.0);

            Debug.Log($"Based on pegBreakCount:{pegBreakCount}, multiplying our force by {pegBreakCountMod}");

            Vector2 puckDampeningForce = pegBreakCountMod * pegsForceOnPuck;

            Debug.Log($"Final force acting on the Puck: {puckDampeningForce}");

            puckBody.velocity = v + puckDampeningForce;
            Debug.Log($"Puck's new velocity is: {puckBody.velocity}");
        }
示例#3
0
 public PuckCombo(Puck hero)
     : base(hero)
 {
     this.Puck = hero;
     UpdateManager.Subscribe(OnUpdate, 25);
     EscapeHandler = UpdateManager.Run(PuckPrisonBreak);
 }
示例#4
0
 //private Vector3 Previous_position;
 void CheckInputs()
 {
     if (Input.GetMouseButton(0))
     {
         //None of the UI Elements are selected.
         //So, check if the Puck is selected.
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit, Mathf.Infinity))
         {
             Debug.DrawLine(Puck.Get().rigidbody.position, hit.point, Color.cyan);
             if (hit.collider.name.Contains("Puck"))
             {
                 m_MouseStartPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Depth);
                 if (!easyslidehack)
                 {
                     EasySlide     = m_MouseStartPos;
                     easyslidehack = true;
                 }
                 m_IsPuckSelected = true;
                 var lock_puck = new Vector3(hit.point.x,
                                             Puck.Get().transform.position.y,
                                             hit.point.z - CorrectionforMouse);
                 lock_puck.x = Mathf.Clamp(lock_puck.x, -0.37f, 0.37f);
                 Puck.Get().rigidbody.position = lock_puck;
                 //Previous_position = lock_puck;
             }
         }
     }
     else if (Input.GetMouseButtonUp(0))
     {
         this.Pucklaunch();
     }
 }
示例#5
0
    void parentHockeyObject()
    {
        if (!GetComponentInChildren <Puck>())
        {
            Puck p = FindObjectOfType <Puck>();
            p.transform.parent = gameObject.transform;

            puck = p.gameObject;
        }

        if (!GetComponentInChildren <HockeyStriker>())
        {
            HockeyStriker[] strikers = FindObjectsOfType <HockeyStriker>();
            foreach (HockeyStriker s in strikers)
            {
                s.transform.parent = gameObject.transform;
                s.parentObject     = this.gameObject;
                if (player1 == null)
                {
                    player1 = s.gameObject;
                }
                else if (player2 == null)
                {
                    player2 = s.gameObject;
                }
            }
        }
    }
示例#6
0
 private void OnEnable()
 {
     puck = GetComponent <PuckBeh>().Puck;
     gestures.OnDragStart += HandleFlickStart;
     gestures.OnDragStop  += HandleFlickStop;
     gestures.OnDrag      += HandleDrag;
 }
示例#7
0
文件: PegSmasher.cs 项目: coshm/SPFT
        public void OnPuckPegCollision(PuckPegCollisionEvent puckPegCollisionEvent)
        {
            if (IsActive && pegBreakCount < maxPegBreaks)
            {
                Puck        puck        = puckPegCollisionEvent.puck;
                Rigidbody2D puckBody    = puck.GetComponent <Rigidbody2D>();
                Collider2D  pegCollider = puckPegCollisionEvent.collision.collider;
                Peg         peg         = pegCollider.GetComponent <Peg>();

                // Ignore collision with this peg
                Collider2D puckCollider = puck.GetComponent <Collider2D>();
                Physics2D.IgnoreCollision(pegCollider, puckCollider);

                // Smash Peg
                SmashPeg(pegCollider, puckBody);
                pegBreakCount++;

                // Dampen momentum of Puck after it smashes the Peg
                DampenPuckMomentum(peg, puck);

                StartCoroutine(StutterPuckMovement(puckBody));

                if (pegBreakCount >= maxPegBreaks)
                {
                    Deactivate();
                }
            }
        }
示例#8
0
文件: Trail.cs 项目: CSLU/Pong
 /// <summary>
 /// Constructor for trail object - this follows the puck as a particle
 /// </summary>
 /// <param name="content">Content manager for loading texture</param>
 /// <param name="p">Puck to follow</param>
 public Trail(ContentManager content, Puck p)
 {
     this.Texture = content.Load<Texture2D>("sprites\\puck");
     this.p = p;
     this.drop = (float)(new Random().NextDouble()) * 0.4f + 0.8f;
     this.Position = p.Position;
 }
 public TouchLink()
 {
     this.playerId  = 0;
     this.pos       = Vector2.zero;
     this.Target    = null;
     this.RigidBody = null;
     this.Puck      = null;
 }
示例#10
0
        public static bool GoesIntoNet(this Puck puck)
        {
            var me = Current.World.GetMyPlayer();
            var a  = puck.GetDistanceTo(me.NetFront, puck.Y) / puck.X;

            var futurePuckY = Math.Abs(a) * puck.SpeedY + puck.Y;

            return(futurePuckY < me.NetBottom && futurePuckY > me.NetTop);
        }
示例#11
0
 new void Awake()
 {
     base.Awake();
     hockeyPlayer = GetComponent<HockeyPlayer>();
     puck = GameObject.Find("Puck").GetComponent<Puck>();
     puckTransform = puck.GetComponent<Transform>();
     goalBox = hockeyPlayer.ownGoal.Find("GoalBox");
     goalBoxCollider = goalBox.GetComponent<BoxCollider>();
 }
示例#12
0
    public void HitStorm(Puck puck)
    {
        SphereSurfaceSlider otherSlider = puck.GetComponent <SphereSurfaceSlider>();

        if (otherSlider && puck)
        {
            otherSlider.HitByStormWithSphericalVelocity(0.5f * slider.sphericalVelocity);
            GameObject.Destroy(gameObject);
        }
    }
示例#13
0
    //float timeElapsed = 0f;

    void Awake()
    {
        Instance    = this;
        _basePos    = transform.position;
        m_Transform = gameObject.transform;
        //m_RigidBody = gameObject.GetComponent<Rigidbody> ();
        //m_DefaultPosition = gameObject.transform.position;
        //Physics.IgnoreLayerCollision(8, 10);
        //Properties.S_CantakeInputs = true;d
    }
示例#14
0
    void OnCollisionEnter(Collision collision)
    {
        Puck puck = collision.collider.GetComponent <Puck>();
        SphereSurfaceSlider otherSlider = collision.collider.GetComponent <SphereSurfaceSlider>();

        if (otherSlider && puck)
        {
            otherSlider.HitByStormWithSphericalVelocity(slider.sphericalVelocity);
            GameObject.Destroy(gameObject);
        }
    }
        public Task <bool> Flick(Puck puck, Vector2 scaledDirection, float percent)
        {
            if (!puck.IsFlickable)
            {
                return(Task.FromResult(false));
            }
            var taskSource = new TaskCompletionSource <bool>(TaskCreationOptions.AttachedToParent);

            puck.Mono.StartCoroutine(RunFlickRoutine(taskSource, puck, scaledDirection, percent));
            return(taskSource.Task);
        }
示例#16
0
 public void ClearAllPuckChordLines()
 {
     foreach (var Puck in PianoPucks)
     {
         foreach (var Puckline in Puck.GetComponent <PianoRollPuck>().VisualSteps)
         {
             //makes all chord indicators, for the lesson, invisable
             Puckline.GetComponent <SpriteRenderer>().enabled = false;
         }
     }
 }
示例#17
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Puck puck = (Puck)target;  // < Преобразование в нужный тип

        if (GUILayout.Button("Add force to Puck"))
        {
            //действия при нажатии на кнопку...
            puck.Rigidbody.AddForce(_origin * _power);
        }
    }
示例#18
0
    void Update()
    {
        float movement = (Input.GetAxis(axis) * movSpeed);

        GetComponent <Rigidbody>().velocity = new Vector3(0, 0, movement);

        if (Input.GetButtonDown("Shoot") && puck != null)
        {
            puck.Launch(shootsLeftToRight);
            puck = null;
        }
    }
示例#19
0
    void OnTriggerExit(Collider other)
    {
        //Hackey way to reset puck if it gone out of the table
        //This is not final we have to fix the PUCK going out of table bug.
        if (other.name.Contains("Puck"))
        {
            Debug.LogError("PUCK gone out of table, \nVelocity: " + other.rigidbody.velocity.magnitude);
            Debug.LogError("\nForce: " + other.rigidbody.velocity + "resetting it (it's a HACK, dont forget to Fix!!)");

            Puck.Get().ResetPuck();
        }
    }
示例#20
0
 private void Update()
 {
     _timer -= Time.deltaTime;
     if (_timer <= 0)
     {
         Shooter randomShooter = GetRandomShooter();
         Puck    nextPuck      = GetNextPuck();
         randomShooter.AddToShootQueue(nextPuck);
         randomShooter.Shoot();
         ShootPuckEvent.Raise <ShootPuckArgs>(randomShooter, new ShootPuckArgs(nextPuck));
         _timer = _shootInterval;
     }
 }
示例#21
0
    private void OnCollisionEvent(System.Object sender, EventArgs args)
    {
        ColliderArgs colliderArgs = args as ColliderArgs;

        if (colliderArgs != null)
        {
            Puck tempPuck = colliderArgs.Collision.gameObject.GetComponent <Puck>();
            if (tempPuck != null && _puckToSave != null && _puckToSave.Equals(tempPuck))
            {
                SavePuckEvent.Raise(sender, args);
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     if (name.Equals("blueTeam"))
     {
         opponent = GameObject.Find("redTeam").GetComponent <Team>();
     }
     else if (name.Equals("redTeam"))
     {
         opponent = GameObject.Find("blueTeam").GetComponent <Team>();
     }
     puck = GameObject.FindObjectOfType <Puck>();
     clearPlayerRolesAndColors();
 }
示例#23
0
 void setCurrentPuck()
 {
     GameObject[] balls = GameObject.FindGameObjectsWithTag("Ball");
     if (balls.Length != 0)
     {
         this.puck = findLowestBall(balls);
     }
     else
     {
         ballsOnField = false;
         PauseAIAndReturnToMiddle();
     }
 }
示例#24
0
    public TouchLink(int playerId, Vector2 pos, GameObject Target, Rigidbody2D RigidBody, Puck Puck)
    {
        this.playerId  = playerId;
        this.pos       = pos;
        this.Target    = Target;
        this.RigidBody = RigidBody;
        this.Puck      = Puck;

        this.Puck.idle = false;
        this.Puck.animator.SetBool("Idle", false);
        this.Puck.trail.enabled = true;
        //animator idle false
        this.Puck.followFinger = true;
    }
示例#25
0
    void Update()
    {
        if (Properties.isPopUpShown)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (!Properties.S_CantakeInputs)
        {
            if (m_IsPuckSelected && m_LineCrossed && easyslidehack)
            {
                Debug.Log("releasing the puck");

                Vector3 m_MouseEndPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Depth);
                Vector3 force         = (m_MouseEndPos - EasySlide);
                var     Zforce        = force.magnitude / Time.deltaTime;
                force = new Vector3(-force.x, 0, -Zforce);
                Debug.Log(force);
                if (force.magnitude > 0.3f)
                {
                    Puck.Get().LaunchPuck(force);
                }
                else
                {
                    Puck.Get().rigidbody.velocity = Vector3.zero;
                    Puck.Get().ResetPuck();
                }
                m_IsPuckSelected = false;
                easyslidehack    = false;
            }
            return;
        }
        this.CheckInputs();
        if (Puck.Get() != null)
        {
            if ((Puck.Get().transform.position.x > 0.15f || Puck.Get().transform.position.x < -0.15f) &&
                m_LineCrossed == false &&
                Input.GetMouseButtonUp(0) &&
                Puck.Get().transform.position.z < 1.90f)
            {
                StartCoroutine("Follow_camera");
            }
        }
    }
    IEnumerator AIActivationStep2()
    {
        yield return(new WaitForSeconds(0.1f));                                                 // Ждём 1 секунду

        if (IHaveThePuck())                                                                     // Вычисляем. Шайба у компьютера? Если метод вернёт правда
        {
            StartCoroutine(Inning());                                                           // Вызываем метод запускающий подачу
        }
        else                                                                                    // Если вернёт ложь
        {
            InningWas = true;                                                                   // Сообщаем что подача была выполненна
        }
        PR = GM.Puck.GetComponent <Rigidbody>();                                                // Получаем объект класса Rigitbody и ложим в переменную PR
        Pc = GM.Puck.GetComponent <Puck>();                                                     // Получаем объект класса Puck и ложим в переменную Pc
    }
 /// <summary>
 /// puckが塗りつぶす色を変更する
 /// </summary>
 /// <param name="pad">puckに当たったpad</param>
 /// <param name="puck">対象のpuck</param>
 public void ChangeColor(GameObject pad, Puck puck)
 {
     if (pad == humanPadObj)
     {
         puck.UpdateLastCollisionPlayer(PlayerType.Human);
     }
     else if (pad == aiPadObj)
     {
         puck.UpdateLastCollisionPlayer(PlayerType.Ai);
     }
     else
     {
         puck.UpdateLastCollisionPlayer(PlayerType.None);
     }
 }
示例#28
0
    public void SpawnPuck(int owner)
    {
        Vector3 pos = new Vector3(Random.Range(deadZone, spawnAreaWidth / 2f), Random.Range(-(spawnAreaHeight / 2f), spawnAreaHeight / 2f), 0);

        if (owner == 1)
        {
            pos.x = -pos.x;
        }
        Puck newPuck = Instantiate(puckPrefabs, pos, Quaternion.identity).GetComponent <Puck>();

        newPuck.SwitchOwner(owner);
        if (Random.Range(0f, 100f) < specialPuckSpawnChance)
        {
            newPuck.SetSpecialPuck();
        }
    }
示例#29
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        int collisionId = 0;

        if (collision.gameObject.tag == "Wall")
        {
            collisionId = collision.gameObject.GetComponent <Wall>().GetId();
            SoundManager.instance.PlayBounceSFX();

            if (id != collisionId)
            {
                changeOwnerNextUpdate = true;
            }
            else
            {
            }
        }
        else if (collision.gameObject.tag == "Grey Wall")
        {
            SoundManager.instance.PlayBounceSFX();
        }
        else if (collision.gameObject.tag == "Puck")
        {
            if (!idle)
            {
                SoundManager.instance.PlayPengouinBounceSFX();
            }
            Puck collidedpuck = collision.gameObject.GetComponent <Puck>();
            collisionId = collidedpuck.GetId();
            //PHYSICS
            collidedpuck.PuckCollision(idle);
            //

            if (id != collisionId)
            {
                changeOwnerNextUpdate = true;
            }
            else
            {
            }
        }
        else
        {
            return;
        }
    }
示例#30
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "RightBorder")
     {
         gameController.PuckIsDestroy(this);
         Destroy(gameObject);
     }
     else if (other.tag == "LeftBorder")
     {
         direction = getNewDirectionAfterCollision(new Vector3(0, 0, 1));
     }
     else if (other.tag == "Stick" || other.tag == "Stick2" || other.tag == "StickOnline")
     {
         direction = getNewDirectionAfterCollision(new Vector3(0, 0, -1));
         AddScore(2);
         getStickBoost();
         gameController.hitStick();
         particuleController.StickCollision(rb.position);
     }
     else if (other.tag == "TopBorder")
     {
         direction = getNewDirectionAfterCollision(new Vector3(1, 0, 0));
         AddScore(1);
     }
     else if (other.tag == "BottomBorder")
     {
         direction = getNewDirectionAfterCollision(new Vector3(-1, 0, 0));
         AddScore(1);
     }
     else if (other.tag == "Ball")
     {
         rb.position = position;
         Puck    otherPuck = other.gameObject.GetComponent <Puck>();
         Vector3 normal    = calculateNormal(otherPuck.getDirection());
         direction = getNewDirectionAfterCollision(normal);
         particuleController.BallCollision(position);
     }
     else if (other.tag == "Obstacle")
     {
         AddScore(5);
         Vector3 collisionPosition = getNewDirectionAfterCollisionWithObstacle(other.gameObject.GetComponent <Rigidbody>().position, other.bounds.size.x);
         particuleController.ObstacleCollision(position);
     }
     other.GetComponent <AudioSource>().volume = soundManager.sfxVolume;
     other.GetComponent <AudioSource>().Play();
 }
        private Puck[] ReadPucks()
        {
            int puckCount = ReadInt();

            if (puckCount < 0)
            {
                return(null);
            }

            Puck[] pucks = new Puck[puckCount];

            for (int puckIndex = 0; puckIndex < puckCount; ++puckIndex)
            {
                pucks[puckIndex] = ReadPuck();
            }

            return(pucks);
        }
        /// <summary>
        /// Clears up the match - removes goalposts and puck, ad decides the winning team.
        /// </summary>
        public void EndGame()
        {
            bool redWon = false;

            if (m_redScore >= 3)
            {
                redWon = true;
            }

            //By default, blue has won, unless red has.

            string winner = (redWon) ? "Reds" : "Blues";

            foreach (GamePlayer pl in PlayingPlayers)
            {
                if (pl == null)
                {
                    continue;
                }
                if (pl.ObjectState != GameObject.eObjectState.Active)
                {
                    continue;
                }

                //Inform the players of the winner!
                pl.Out.SendMessage("The game is over! Congratulations to the winning team, the " + winner + "!", DOL.GS.PacketHandler.eChatType.CT_Broadcast, DOL.GS.PacketHandler.eChatLoc.CL_ChatWindow);

                //Remove the stick from the player.
                RemoveStick(pl);
            }

            if (Puck != null)
            {
                Puck.RemoveFromWorld();
                Puck.Delete();
            }

            playState = ePlayState.Waiting;

            //Flush player lists...
            m_redTeam        = new List <GamePlayer>();
            m_blueTeam       = new List <GamePlayer>();
            m_playingPlayers = new List <GamePlayer>();
        }
示例#33
0
文件: Pad.cs 项目: CSLU/Pong
 /// <summary>
 /// Check to see if the puck has collided with the pad, if so, reverse the pucks direction
 /// </summary>
 /// <param name="p">Puck object</param>
 public void checkCollisionAndRebound(Puck p)
 {
     if (this.bbox.Intersects(p.bbox))
     {
         if (!rebounding)
         {
             float diff = Math.Abs(p.Position.Y - this.Position.Y);
             float fulldiff = this.Size.Height;
             float speed = (((diff / fulldiff)) * p.SPEED) - p.SPEED / 2;
             p.flipX();
             p.setAngle(speed);
             rebounding = true;
         }
     }
     else
     {
         rebounding = false;
     }
 }
示例#34
0
    /*
     * Receive
     * Receive a puck
     * @param Puck p, the puck
     */
    public void Receive(Puck p)
    {
        if (!ready)
            return;

        puck = p;
        puck.transform.parent = puckLaunch;
        puck.transform.localPosition = Vector3.zero;
        cradleBonusTimer.Start ();
    }
示例#35
0
    /*
     * Hit
     * @param Puck puck
     */
    public bool Hit(Puck puck)
    {
        if(!hitTimer.running)
        {
            //	We're an ordered target, check with headquarters that there are none in higher priority at play
            if(priority > 0)
            {
                if(!LowestPriority())
                {
                    return false;
                }
            }

            else if(reinforced)
            {
                UnReinforce();
                puck.validHit = true;
                return false;
            }
            else if(hazardous)
            {
                puck.HitHazard();
                GetComponent<Animator>().SetTrigger("Hit");
                GetHit();
                return false;
            }

            GetComponent<Animator>().SetTrigger("Hit");
            GetHit();
            return true;
        }
        return false;
    }
示例#36
0
文件: Game1.cs 项目: CSLU/Pong
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            p = new Puck(Content, new Rectangle(0,0,this.graphics.GraphicsDevice.Viewport.Width, this.graphics.GraphicsDevice.Viewport.Height));
            leftPad = new Pad(Content, new Rectangle(0, 0, this.graphics.GraphicsDevice.Viewport.Width, this.graphics.GraphicsDevice.Viewport.Height), true);
            rightPad = new Pad(Content, new Rectangle(0, 0, this.graphics.GraphicsDevice.Viewport.Width, this.graphics.GraphicsDevice.Viewport.Height), false);

            leftScorePos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 10, this.graphics.GraphicsDevice.Viewport.Height * 0.02f);
            rightScorePos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width - this.graphics.GraphicsDevice.Viewport.Width / 10, this.graphics.GraphicsDevice.Viewport.Height * 0.02f);
            ballsLeftPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width/2, this.graphics.GraphicsDevice.Viewport.Height * 0.02f);
            winnerPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width/2 - 200, this.graphics.GraphicsDevice.Viewport.Height/2 - 100);
            winnerTextPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width/2, this.graphics.GraphicsDevice.Viewport.Height/2);
            ballTextPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 2, this.graphics.GraphicsDevice.Viewport.Height / 2 + 10);
            ballTextLabelPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 2, this.graphics.GraphicsDevice.Viewport.Height / 2 - 10);
            nextgameTextLabelPos = new Vector2(this.graphics.GraphicsDevice.Viewport.Width / 2, this.graphics.GraphicsDevice.Viewport.Height / 2 + 70);
            ballsLeft = BALLS_START;

            gamestate = MAIN_GAME_STATE;
            trails = new Trail[NUM_TRAILS];

            base.Initialize();
        }
示例#37
0
    /*
     * Take a shot
     */
    public void Shoot()
    {
        //	Don't shoot if the rounds over
        if(!control.roundRunning)
            return;

        //	Check if we hit anything with the previous puck
        if(prevPuck != null)
        {
            if(!prevPuck.validHit)
                control.ResetMultiplier();
        }

        if(puck != null)
        {
            //	Get the aim
            //aim = new Vector2(Mathf.Cos (joystick.coordinates.x), Mathf.Sin (joystick.coordinates.x))*joystick.coordinates.y;
            //	We're guna launch the puck based on our aim and accuracy

            //	First we're guna pick a point around the net where the puck is guna go, based on the center of the net
            puck.transform.parent = transform.parent;
            puck.ShootTowards(GetAimPos(), power);
            puck.AddNetCollision(control.net);

            prevPuck = puck;
            puck = null;
            control.ShotMade();

            if(animator.GetFloat("Cradle") > 0.5f)
                AudioControl.PlaySoundEffect("common_shot"+(Random.Range (0,2)==0?"1":"3"));
            else
                AudioControl.PlaySoundEffect("common_shot2");

            animator.SetTrigger ("Shoot");

            // Check for tutorial conditions
            if (control.gameType == Control.GameType.TUTORIAL)
            {
                if(animator.GetFloat("Cradle") > 0.2f)
                {
                    if(aimTimer.percentLeft < 0.75f)
                        MenuControl.sharedMenu.GetMenu ("Tutorial").GetComponent<TutorialMenu> ().CompleteObjective (TutorialMenu.SlideType.WRIST);
                }
                else
                    MenuControl.sharedMenu.GetMenu ("Tutorial").GetComponent<TutorialMenu> ().CompleteObjective (TutorialMenu.SlideType.SHOOTING);
            }

        }
        aiming = false;
        aimTimer.Stop();

        cradleHold = 0;
        shotCooldown.Start ();
    }