Exemple #1
0
        public override void Update()
        {
            ElapsedTime += Time.ElapsedMilliseconds;

            Cursor.Position = ActionCmd.CursorPosition;
            Cursor.Rotation = ActionCmd.CursorRotation;

            //Remove the thrown cursor if enough time passed
            if (ThrownCursor != null && ElapsedTime >= ActionCmd.ThrownCursorTime)
            {
                ThrownCursor = null;
            }
            else if (ThrownCursor == null && ElapsedTime < ActionCmd.ThrownCursorTime)
            {
                //Create the cursor
                ThrownCursor           = Cursor.Copy();
                ThrownCursor.Depth    -= .01f;
                ThrownCursor.TintColor = Color.Gray;
            }
        }
        private void ThrowBomb()
        {
            double angleRadians = UtilityGlobals.ToRadians(CursorAngle);

            Vector2 throwVelocity = new Vector2((float)Math.Cos(angleRadians) * BaseThrowVelocity.X, (float)Math.Sin(angleRadians) * BaseThrowVelocity.Y);

            //Debug.Log($"CursorAngle: {angleRadians}, ThrowVelocity: {throwVelocity}, Cos: {Math.Cos(angleRadians)}, Sin: {Math.Sin(angleRadians)}");

            NumBombsThrown++;

            LastBombThrowTime = ElapsedTime + AutomaticThrowTime;
            ThrownCursorTime  = ElapsedTime + ThrownCursorDur;

            //Show a grey cursor indicating this is where the bomb was thrown for 1 second
            CursorThrownPosition   = Cursor.Position;
            ThrownCursor           = Cursor.Copy();
            ThrownCursor.Depth    -= .01f;
            ThrownCursor.TintColor = Color.Gray;

            SendResponse(new ActionCommandGlobals.BombSquadResponse(throwVelocity, ThrowGravity));
        }