public async Task <DancerResponse> UpdateAsync(int id, Dancer user)
        {
            var existingFella = await userRepository.FindById(id);

            if (existingFella == null)
            {
                return(new DancerResponse("ERROR: User not found."));
            }

            existingFella.Name     = user.Name;
            existingFella.LA       = user.LA;
            existingFella.ST       = user.ST;
            existingFella.PointsLA = user.PointsLA;
            existingFella.PointsST = user.PointsST;

            try
            {
                userRepository.Update(existingFella);
                await unitOfWork.CompleteAsync();

                return(new DancerResponse(existingFella));
            }
            catch (Exception e)
            {
                return(new DancerResponse($"An error occurred when updating the category: {e.Message}"));
            }
        }
Exemple #2
0
 public override Path performOne(Dancer d, CallContext ctx)
 {
     if (d.data.leader)
     {
         //  Find another active dancer in the same line and move to that spot
         Dancer d2 = ctx.dancerClosest(d, dx => dx.data.active &&
                                       (CallContext.isRight(d)(dx) || CallContext.isLeft(d)(dx)));
         if (d2 != null)
         {
             double dist = CallContext.distance(d, d2);
             return(TamUtils.getMove(CallContext.isRight(d)(d2) ? "Run Right" : "Run Left")
                    .scale(dist / 3, dist / 2).changebeats(4.0));
         }
     }
     else if (d.data.trailer)
     {
         //  Looking at active leader?  Then take its place
         //  TODO maybe allow diagonal circulate?
         Dancer d2 = ctx.dancerInFront(d);
         if (d2 != null && d2.data.active)
         {
             double dist = CallContext.distance(d, d2);
             return(TamUtils.getMove("Forward").scale(dist, 1.0).changebeats(4.0));
         }
     }
     throw new CallError("Cannot figure out how to Circulate.");
 }
Exemple #3
0
    /// <summary>
    /// Steps in the direction of the vector given to see if the tile is free
    /// </summary>
    /// <param name="dX">dancer x</param>
    /// <param name="dY">dancer y</param>
    /// <param name="v">vector to check</param>
    /// <param name="length">distance to check</param>
    /// <param name="d">dancer</param>
    void CastValidTile(int dX, int dY, Vector2 v, int length, Dancer d)
    {
        for (int i = 0; i < length + 1; i++)
        {
            Vector2 check = new Vector2(dX, dY) + (v * i);
            if (IsValidPos(check, d))
            {
                //Change tile col
                var   t = Tiles[(int)check.y, (int)check.x];            //The valid tile
                Color c = i == 0 ? SelectedOriginColor : SelectedColor; //Set different color if origin
                //painter.AddToLayer(0, check, c);

                //Adderino dancer if can
                List <Vector2> poslist;
                _validPositions.TryGetValue(d, out poslist);

                if (!poslist.Contains(check))
                {
                    poslist.Add(check);
                }
            }
            else if (i > 0) //if newpos is not start position
            {
                return;
            }
        }
    }
Exemple #4
0
        public override Path performOne(Dancer d, CallContext ctx)
        {
            //  Find the dancer to hinge with
            Dancer d2 = null;
            var    d3 = ctx.dancerToRight(d);
            var    d4 = ctx.dancerToLeft(d);
            var    d0 = d.data.partner;

            if (d0 != null && d0.data.active)
            {
                d2 = d0;
            }
            else if (d3 != null & d3.data.active)
            {
                d2 = d3;
            }
            else if (d4 != null && d4.data.active)
            {
                d2 = d4;
            }
            if (d2 == null)
            {
                throw new CallError($"Dancer {d.number} cannot Hinge");
            }
            var m = CallContext.isRight(d)(d2) ? "Hinge Right" : "Hinge Left";

            return(TamUtils.getMove(m));
        }
 public FollowingDancerBehavior(Dancer me, Dancer following)
 {
     _me = me;
     _following = following;
     SetWaypoint();
     _me.SetAnimation("Conga");
 }
Exemple #6
0
    //Returns dancers in range of a conga
    //0 is top, 1 is bot
    public List <Dancer> Conga_Range(Vector2 pos, int range, Vector2 cardinality)
    {
        //Get just the tips
        Vector2 top;

        top = (cardinality * (range - 1)) + pos; //Assumes range = length of line

        Dancer dtop = null;                      //null if not found
        Dancer dBot = null;

        //find targets in range (only one since that's all we need for push to work)
        for (int i = 1; i < range + 1; i++)
        {
            if (!dtop)                                                        //top
            {
                dtop = board.GetDancer(top + (cardinality * i), !board.turn); //Look for enemies
            }
            if (!dBot)                                                        //bot
            {
                dBot = board.GetDancer(pos - (cardinality * i), !board.turn);
            }
        }

        List <Dancer> returnList = new List <Dancer>();

        returnList.Add(dtop);
        returnList.Add(dBot);

        return(returnList);
    }
Exemple #7
0
    /// <summary>
    /// Forces a dancer to a position, knocks all others out of the way
    /// Doesn't work diagonally! Delta must have a magnitude of 1 max!
    /// </summary>
    /// <param name="v">the change in position (eg strength of move)</param>
    public void Push(Dancer d, Vector2 delta)
    {
        //Debug
        RecurseDepth++;
        if (RecurseDepth > 50)
        {
            Debug.Log("uh oh! Max recurse depth reached!");
            RecurseDepth = 0;
            return;
        }

        //can't move diagnonally
        Debug.Assert(!(delta.x > 0 && delta.y > 0));

        var     pos    = GetDancerPos(d);
        Vector2 EndPos = pos + delta; //Position dancer will end up at

        Dancer pushDancer;

        if (InBounds(EndPos) && _Dancers.TryGetValue(EndPos, out pushDancer)) //If next space is full
        {
            d.Stumble();
            Push(pushDancer, delta);
            Move(d, EndPos);
        }
        else //Space is free or we've reached the end of the board
        {
            d.Stumble();
            Move(d, EndPos);
        }

        RecurseDepth = 0;
    }
Exemple #8
0
 public override Path performOne(Dancer d, CallContext ctx)
 {
     if (d.data.leader)
     {
         var d2 = ctx.dancerInBack(d);
         if (d2 == null || !d2.data.active)
         {
             throw new CallError($"Trailer of {d} must also Zoom");
         }
         var a    = CallContext.angle(d);
         var c    = a < 0 ? "Run Left" : "Run Right";
         var dist = CallContext.distance(d, d2);
         return(TamUtils.getMove(c).changebeats(2).skew(-dist / 2, 0)
                .add(TamUtils.getMove(c).changebeats(2).skew(dist / 2, 0)));
     }
     else if (d.data.trailer)
     {
         var d2 = ctx.dancerInFront(d);
         if (d2 == null || !d2.data.active)
         {
             throw new CallError($"Leader of {d} must also Zoom");
         }
         var dist = CallContext.distance(d, d2);
         return(TamUtils.getMove("Forward").changebeats(4).scale(dist, 1));
     }
     else
     {
         throw new CallError($"Dancer {d} cannot Zoom");
     }
 }
Exemple #9
0
        public override string select(CallContext ctx, Dancer d)
        {
            //  Look at the last curve of the past
            var roll = d.path.movelist.Last().brotate.rolling();

            return(roll <-0.1 ? "Quarter Right" : roll> 0.1 ? "Quarter Left" : "Stand");
        }
Exemple #10
0
    /// <summary>
    /// Moves a dancer to a postion. Will knock the dancer out if moved off the floor
    /// </summary>
    /// <param name="d">dancer to move</param>
    /// <param name="newpos">position to move to</param>
    public void Move(Dancer d, Vector2 newpos)
    {
        //Knock out!
        if (!InBounds(newpos) && d.isDancing)
        {
            Vector2 dir = (newpos - GetDancerPos(d));
            RemoveDancer(d, dir * LaunchForce);

            //Win state check
            if (CountDancers(turn ? Player2 : Player1) < 3 || d.IsLead)
            {
                GameState.me.ChangeState(eGameState.GAME_END);
            }
        }
        else if (InBounds(newpos) && d.isDancing) //All good
        {
            //Update Dict
            var oldKey = GetDancerPos(d);
            _Dancers.Remove(oldKey);
            _Dancers.Add(newpos, d);

            //Update world newpos
            var p = new Vector3(newpos.x, 0, newpos.y);
            d.UpdateTarget(p);
        }
    }
Exemple #11
0
 public override void perform(CallContext ctx, int i)
 {
     ctx.levelBeats();
     ctx.dancers.ForEach(d => {
         if (d.data.active)
         {
             //  Active dancers spread apart
             String m;
             if (ctx.dancersToRight(d).Count() == 0)
             {
                 m = "Dodge Right";
             }
             else if (ctx.dancersToLeft(d).Count() == 0)
             {
                 m = "Dodge Left";
             }
             else
             {
                 throw new CallError("Can not figure out how to Spread");
             }
             d.path.add(TamUtils.getMove(m).changebeats(2.0));
         }
         else
         {
             //  Inactive dancers move forward
             Dancer d2 = ctx.dancerInFront(d);
             if (d2 != null)
             {
                 double dist = CallContext.distance(d, d2);
                 d.path.add(TamUtils.getMove("Forward").scale(dist, 1.0).changebeats(2.0));
             }
         }
     });
 }
        public override Path performOne(Dancer d, CallContext ctx)
        {
            var offsetX = 0.0;
            var move    = select(ctx, d);

            //  If leader or trailer, make sure to adjust quarter turn
            //  so handhold is possible
            if (move != "Stand")
            {
                if (d.data.leader)
                {
                    var d2   = ctx.dancerInBack(d);
                    var dist = CallContext.distance(d, d2);
                    if (dist > 2)
                    {
                        offsetX = -(dist - 2) / 2;
                    }
                }
                if (d.data.trailer)
                {
                    var d2   = ctx.dancerInFront(d);
                    var dist = CallContext.distance(d, d2);
                    if (dist > 2)
                    {
                        offsetX = (dist - 2) / 2;
                    }
                }
            }
            return(TamUtils.getMove(move).skew(offsetX, 0.0));
        }
Exemple #13
0
    /// <summary>
    /// Outlines the tiles where the player can go
    /// </summary>
    void FindValidTiles(Dancer d)
    {
        //var dX = (int)d.StartRoundPos.x;
        //var dY = (int)d.StartRoundPos.y;

        var dX = (int)d._target.x;
        var dY = (int)d._target.z;

        //Loop through all directions to check
        for (int i = -1; i < 2; i++)
        {
            for (int j = -1; j < 2; j++)
            {
                int range    = d.rangePoints;
                var VecCheck = new Vector2(j, i);

                //Decrease range for diags
                if (!(VecCheck.x == 0 || VecCheck.y == 0))
                {
                    range -= 1;
                }

                CastValidTile(dX, dY, VecCheck, range, d);
            }
        }
    }
    private void Start()
    {
        player         = FindObjectOfType <ADV_Player>();
        playerStartPos = player.transform.position;
        stepSelectors  = GetComponentsInChildren <PassSelector>();
        RouteFollower[] robots = GetComponentsInChildren <RouteFollower>();
        panel      = GameObject.Find("MessageBox");
        messageTXT = panel.GetComponentInChildren <Text>();
        panel.SetActive(false);
        for (int i = 0; i < stepSelectors.Length; i++)
        {
            stepSelectors[i].gameObject.SetActive(false);
            Dancer d = new Dancer();
            d.follower   = robots[i];
            d.startPoint = d.follower.transform.position;
            d.icon       = robots[i].gameObject.GetComponentInChildren <SpriteRenderer>();
            d.anim       = robots[i].gameObject.GetComponent <Animator>();
            switch (i)
            {
            case 0: d.danceName = "SAMBA"; break;

            case 1: d.danceName = "SALSA"; break;

            case 2: d.danceName = "MACARENA"; break;
            }
            dancers.Add(d);
            dancers[i].follower.addWayPoint(d.startPoint);
        }

        Invoke("activeAll", 3);
    }
Exemple #15
0
        public override Path performOne(Dancer d, CallContext ctx)
        {
            var v   = d.location;
            var v2  = v;
            var cy4 = 0.0;
            var y4  = 0.0;
            var a1  = d.tx.Angle();
            var a2  = v.Angle();
            //  Determine if this is a rotate left or right
            var angdif = a2.angleDiff(a1);

            if (angdif < 0)
            {
                //  Left
                v2  = v.Rotate(Math.PI / 2);
                cy4 = 0.45;
                y4  = 1;
            }
            else
            {
                //  Right
                v2  = v.Rotate(-Math.PI / 2);
                cy4 = -0.45;
                y4  = -1;
            }
            //  Compute the control points
            var dv  = (v2 - v).Rotate(-a1);
            var cv1 = (v2 * 0.5f).Rotate(-a1);
            var cv2 = (v * 0.5f).Rotate(-a1) + dv;
            var m   = new Movement(2.0, Hands.NOHANDS,
                                   cv1.X, cv1.Y, cv2.X, cv2.Y, dv.X, dv.Y, 0.55, 1, cy4, 1, y4);

            return(new Path(m));
        }
Exemple #16
0
    private string[] ToStringArray(Dictionary <Vector2, Dancer> board, int boardW, int boardH)
    {
        //Initalize string array with dancers
        string[] stringBoard = new string[boardH];
        for (int i = 0; i < boardH; i++)
        {
            string row = "";
            for (int j = 0; j < boardW; j++)
            {
                Dancer d = null;
                board.TryGetValue(new Vector2(j, i), out d); //get dancer at pos

                if (!d)
                {
                    row += ".";
                }
                else if (d.IsLead)
                {
                    row += "A";
                }
                else if (d)
                {
                    row += "D";
                }
            }
            stringBoard[i] = row;
        }
        return(stringBoard);
    }
Exemple #17
0
        static void HeadOfLine(Queue male, Queue female)
        {
            Dancer w, m;

            m = new Dancer();
            w = new Dancer();
            if (male.Count > 0)
            {
                m.GetName(male.Peek().ToString());
            }
            if (female.Count > 0)
            {
                w.GetName(female.Peek().ToString());
            }
            if (m.name != " " && w.name != "")
            {
                Console.WriteLine("Next in line are: " + m.name + "\t" + w.name);
            }
            else if (m.name != "")
            {
                Console.WriteLine("Next in line is: " + m.name);
            }
            else
            {
                Console.WriteLine("Next in line is: " + w.name);
            }
        }
Exemple #18
0
 public override string select(CallContext ctx, Dancer d)
 {
     if (d.data.leader)
     {
         return(name.StartsWith("Zig") ? "Quarter Right" : "Quarter Left");
     }
     return("Stand");
 }
Exemple #19
0
    /// <summary>
    /// Remove dancer from board
    /// </summary>
    /// <param name="d">Dancer to remove</param>
    /// <param name="launchVec">How far to launch the dancer using physics</param>
    private void RemoveDancer(Dancer d, Vector2 launchVec)
    {
        var key = GetDancerPos(d);

        d.KnockOut(launchVec);
        _Dancers.Remove(key);
        UI.AnotherOneBitesTheDust(d.Player == Player2);
    }
 public override Path performOne(Dancer d, CallContext ctx)
 {
     if (ctx.isInCouple(d))
     {
         return(TamUtils.getMove(d.data.beau ? "BackSashay Right" : "Sashay Left"));
     }
     throw new CallError("Only Couples can Half Sashay");
 }
    public void initializeController()
    {
        if(dancerObject != null)
            {

                dancer = dancerObject.GetComponent<Dancer>();

            }
    }
Exemple #22
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (other.tag == "Dancer")
     {
         Dancer dancer = other.GetComponent <Dancer>();
         if (dancer.completedDancing)
         {
             Destroy(other.gameObject);
         }
     }
 }
Exemple #23
0
    private void Update()
    {
        if (slapCooldown > 0.0f)
        {
            slapCooldown -= Time.deltaTime;
        }

        for (int i = 1; i <= GameState.MAX_PLAYERS; ++i)
        {
            if (currentWooFactors.ContainsKey(i) && i != takenBy)
            {
                if (currentWooFactors[i] > WOO_IDLE_LIMIT)
                {
                    currentWooFactors[i] -= Time.deltaTime * WOO_DECAY;
                    if (currentWooFactors[i] < WOO_IDLE_LIMIT)
                    {
                        currentWooFactors[i] = WOO_IDLE_LIMIT;
                    }
                }
                else if (currentWooFactors[i] < WOO_IDLE_LIMIT)
                {
                    currentWooFactors[i] += Time.deltaTime * WOO_DECAY;
                    if (currentWooFactors[i] > WOO_IDLE_LIMIT)
                    {
                        currentWooFactors[i] = WOO_IDLE_LIMIT;
                    }
                }
            }
        }
        if (takenBy != NOT_TAKEN)
        {
            gameState.AddScoreForPlayer(takenBy, SCORE_RATE * Time.deltaTime);
            Collider[] collidersInRange = Physics.OverlapSphere(transform.position, 1000.0f);
            Dancer     dancer           = null;
            foreach (var collider in collidersInRange)
            {
                dancer = collider.gameObject.GetComponent <Dancer>();
                if (dancer != null && dancer.PlayerNumber == takenBy)
                {
                    break;
                }
            }
            if (dancer != null && Vector3.Distance(transform.position, dancer.transform.position) > DISTANCE_TOLERANCE)
            {
                GetComponent <Rigidbody>().velocity = (dancer.transform.position - transform.position).normalized * VELOCITY;
            }
            else
            {
                GetComponent <Rigidbody>().velocity = Vector3.zero;
            }
        }
        DetermineAnimation();
    }
Exemple #24
0
    /// <summary>
    /// Checks for a valid board position
    /// </summary>
    /// <param name="v">newpos</param>
    /// <param name="d">the dancer asking</param>
    bool IsValidPos(Vector2 v, Dancer d)
    {
        if (InBounds(v))
        {
            //Doesn't contain a dancer at that position, or the dancer is me
            var    key = new Vector2(v.x, v.y);
            Dancer d2;
            _Dancers.TryGetValue(key, out d2);

            return(!_Dancers.ContainsKey(key) || d == d2);
        }
        return(false);
    }
Exemple #25
0
    public void Boogaloo(Vector2 pos, int range, int push, string[] move, Vector2 cardinality)
    {
        Dancer d = Boogaloo_Range(pos, range, push, move, cardinality);

        //Now pushy pushy
        if (d)
        {
            for (int i = 0; i < push; i++)
            {
                board.Push(d, cardinality);
            }
        }
    }
Exemple #26
0
    void OnEnable()
    {
        lead = _board.GetDancer(new Vector2(3, 1));
        if (!lead)
        {
            return;        //gets called on start for some reason
        }
        lead.canMove = false;

        Invoke("Kickoff", 4);

        advanceButt.interactable = false;
        endTurn.interactable     = false;
    }
 void activeAll()
 {
     if (Soundmanager.instance != null)
     {
         Soundmanager.instance.PlayBgmByName("POP");
     }
     message = "ダンスバトルへようこそ、ロボットのダンスを見ながら" +
               "ステップを覚えて下さい";
     panel.SetActive(true);
     StartCoroutine(writeMessage(message));
     currentDancer = dancers[danceIndex];
     currentDancer.follower.addWayPoint(center);
     battleIsStarted = true;
 }
Exemple #28
0
        public override Path performOne(Dancer d, CallContext ctx)
        {
            //  This is for waves only
            //  Compute offset for spread
            var v = Vector.Create(0, d.data.belle ? 2 : d.data.beau ? -2 : 0);
            //  Pop off the last movement and shift it by that offset
            var m  = d.path.pop();
            var tx = m.rotate();
            var v2 = v.concatenate(tx);

            d.path.add(m.skew(v2.X, v2.Y).useHands(Hands.NOHANDS));
            //  Return dummy path
            return(new Path());
        }
        public override Path performOne(Dancer d, CallContext ctx)
        {
            var d2 = ctx.dancerFacing(d);

            if (d2 != null)
            {
                return(TamUtils.getMove("Extend Right").scale(CallContext.distance(d, d2) / 2, 1)
                       .add(TamUtils.getMove("Hinge Left")));
            }
            else
            {
                throw new CallError($"Dancer {d.number} cannot Touch a Quarter");
            }
        }
Exemple #30
0
        static void Main(string[] args)
        {
            OrchestraAbstractDecorator anchor   = new Anchor();
            OrchestraAbstractDecorator clown    = new Clown();
            OrchestraAbstractDecorator comedian = new Comedian();
            OrchestraAbstractDecorator dancer   = new Dancer();
            OrchestraAbstractDecorator singer   = new Singer();


            while (true)
            {
                Console.WriteLine("Which package you want write \n F for free \n P for premium \n G for gold");
                var input = Console.ReadLine().ToCharArray()[0];
                Console.WriteLine(input.ToString());
                switch (input)
                {
                case 'F':
                case 'f':
                    Console.WriteLine("In free package you get Anchor and singer :)");
                    singer.orchestra = anchor;
                    singer.play();
                    break;

                case 'P':
                case 'p':
                    Console.WriteLine("In premium package you get Anchor, singer, dancer and comedian:)");
                    comedian.orchestra = dancer;
                    dancer.orchestra   = singer;
                    singer.orchestra   = anchor;
                    comedian.play();
                    break;

                case 'G':
                case 'g':
                    Console.WriteLine("In premium package you get Anchor, singer, dancer, comedian and clown:)");
                    clown.orchestra    = comedian;
                    comedian.orchestra = dancer;
                    dancer.orchestra   = singer;
                    singer.orchestra   = anchor;
                    clown.play();
                    break;

                default:
                    Console.WriteLine("whatever you selected you get an anchor : ");
                    anchor.play();
                    break;
                }
            }
        }
Exemple #31
0
        public override string select(CallContext ctx, Dancer d)
        {
            switch (name)
            {
            case "Face In": return(CallContext.angle(d) < 0 ? "Quarter Right" : "Quarter Left");

            case "Face Out": return(CallContext.angle(d) > 0 ? "Quarter Right" : "Quarter Left");

            case "Face Left": return("Quarter Left");

            case "Face Right": return("Quarter Right");

            default: return("Stand");
            }
        }
Exemple #32
0
    /// <summary>
    /// Paints the dancer's valid moves
    /// </summary>
    /// <param name="d"></param>
    private void PaintSelection(Dancer d)
    {
        if (d.rangePoints > 0)
        {
            painter.AddToLayer(0, d.StartRoundPos, SelectedOriginColor); //Origin colour
        }
        List <Vector2> poslist;

        _validPositions.TryGetValue(d, out poslist);

        foreach (Vector2 v in poslist)
        {
            painter.AddToLayer(0, v, SelectedColor);
        }
    }
        public EnterFloorDancerBehavior(Dancer dancer)
        {
            _me = dancer;

            float angle = RandomHelper.GetRandomFloat() * MathHelper.TwoPi;
            // TODO: Make this a global constant?
            float radius = RandomHelper.GetRandomFloat() * 1200f;

            _destination = new Vector3();
            _destination.X = radius * (float)Math.Sin(angle);
            _destination.Y = 0;
            _destination.Z = radius * (float)Math.Cos(angle);

            _me.Forward = Vector3.Normalize(_destination - _me.Position);
            _me.SetAnimation("Walking");
        }
 public IdleDancerBehavior(Dancer dancer)
 {
     dancer.SetAnimation("Dancing");
 }
 public JoinLineDancerBehavior(Dancer me, Dancer following)
 {
     _me = me;
     _following = following;
     _me.SetAnimation("Walking");
 }
 public FallingDancerBehavior(Dancer dancer)
 {
     dancer.SetAnimation("Falling");
     dancer.EnqueueAnimation("Hurting");
 }
 public LeadDancerBehavior(Dancer dancer)
 {
     _dancer = dancer;
     _dancer.SetAnimation("Leader");
 }