Ejemplo n.º 1
0
    Tuple <Direction, int> RandomRelativeDir()
    {
        Randomizer       puppetRandomizer = Randomizer.New(actions.Count - 1);
        int              puppetNumber     = puppetRandomizer.Next();
        TiteresDirection puppet           = actions[puppetNumber];

        Direction d = RandomDirection(puppet.direction == Direction.LEFT || puppet.direction == Direction.RIGHT);

        return(Tuple.Create(d, puppetNumber));
    }
Ejemplo n.º 2
0
    void SetActions(List <int> difficulties, bool withTime)
    {
        actions = new List <TiteresDirection>();
        Direction[]      dirs          = (Direction[])Enum.GetValues(typeof(Direction));
        Randomizer       dirRandomizer = Randomizer.New(dirs.Length - 2);
        TiteresDirection newDir        = null;

        while (actions.Count < difficulties.Count)
        {
            int       current = actions.Count;
            Direction dir     = dirs[dirRandomizer.Next()];
            Tuple <Direction, int> relativeDir = null;

            switch (difficulties[current])
            {
            case 1:
                newDir = new TiteresDirection(dir, TiteresAction.NONE, -1, 1);
                break;

            case 2:
                newDir = new TiteresDirection(dir, RandomAction(true), -1, 2);
                break;

            case 3:
                newDir = new TiteresDirection(dir, RandomAction(false), -1, 3);
                break;

            case 4:
                relativeDir = RandomRelativeDir();
                newDir      = new TiteresDirection(relativeDir.Item1, TiteresAction.NONE, relativeDir.Item2, 4);
                break;

            case 5:
                relativeDir = RandomRelativeDir();
                newDir      = new TiteresDirection(relativeDir.Item1, RandomAction(true), relativeDir.Item2, 5);
                break;

            case 6:
                relativeDir = RandomRelativeDir();
                newDir      = new TiteresDirection(relativeDir.Item1, RandomAction(false), relativeDir.Item2, 6);
                break;
            }

            if (!actions.Contains(newDir) && newDir != null)
            {
                actions.Add(newDir);
            }
        }

        actionsToShow = actions;
        if (withTime)
        {
            Randomizer.RandomizeList(actionsToShow);
        }
    }
Ejemplo n.º 3
0
        bool IsCorrect()
        {
            List <TiteresDirection> actions = model.CurrentLvl().Actions();

            for (int i = 0; i < actions.Count; i++)
            {
                TiteresDirection action  = actions[i];
                Image            dragger = draggers[i];

                if (!IsDirectionCorrect(action, dragger))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        bool IsDirectionCorrect(TiteresDirection action, Image dragger)
        {
            List <Sprite> puppets = new List <Sprite>(Resources.LoadAll <Sprite>("Sprites/TiteresActivity/puppets"));
            int           index   = puppets.IndexOf(dragger.sprite) % 4;

            //Check for action.
            if (action.action == TiteresAction.STANDING && index != 0)
            {
                Debug.Log("not standing");
                return(false);
            }
            if (action.action == TiteresAction.RIGHT_ARM && index != 2)
            {
                Debug.Log("not right arm");
                return(false);
            }
            if (action.action == TiteresAction.LEFT_ARM && index != 1)
            {
                Debug.Log("not left arm");
                return(false);
            }
            if (action.action == TiteresAction.SIT && index != 3)
            {
                Debug.Log("not sitting");
                return(false);
            }

            //Check for direction

            Vector2 draggerPosition = dragger.transform.position;

            Debug.Log("dragger x: " + draggerPosition.x);
            Debug.Log("dragger y: " + draggerPosition.y);

            Vector2 objPosition = action.relativeToPuppetNumber == -1 ? obj.transform.position : draggers[action.relativeToPuppetNumber].transform.position;

            Debug.Log("obj x: " + objPosition.x);
            Debug.Log("obj y: " + objPosition.y);

            if (action.direction == Direction.RIGHT && draggerPosition.x < objPosition.x)
            {
                Debug.Log("not right");
                return(false);
            }
            if (action.direction == Direction.LEFT && draggerPosition.x > objPosition.x)
            {
                Debug.Log("not left");
                return(false);
            }
            if (action.direction == Direction.UP && draggerPosition.y < objPosition.y)
            {
                Debug.Log("not up");
                return(false);
            }
            if (action.direction == Direction.DOWN && draggerPosition.y > objPosition.y)
            {
                Debug.Log("not down");
                return(false);
            }

            return(true);
        }