Ejemplo n.º 1
0
        public bool shoot(Game1.Direction dir)
        {
            if (MyPlayer.getArrows() >= 1)
            {
                Room NextRoom = MyCave.getConnectedRooms(MyMap.getPlayerRoom().getDecimalForm())[(int)(dir)];
                MyPlayer.setArrows(MyPlayer.getArrows() - 1);
                if (NextRoom != null)
                {
                    won = MyMap.ShootArrow(NextRoom);
                    if (won)
                    {
                        GameState = Gstate.EndGame;
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        facingRight = true;

        myRigidBody  = GetComponent <Rigidbody2D>();
        myAnimator   = GetComponent <Animator>();
        currentState = Gstate.Idle;
    }
Ejemplo n.º 3
0
 public void EnterFlying()
 {
     currentState = Gstate.Flying;
     friendFollow.StartCarrying();
     soundManager.playBirdSound();
     //Invoke("DelayedFunction", 3.0f);
     //Debug.Log("is flying");
 }
Ejemplo n.º 4
0
        // When the user presses the "Start Game" button, the state of the game is set to 1 (in game).
        // This happens only when the user is NOT ALREADY in the game.
        public bool startGame()
        {
            if (GameState != Gstate.Game)
            {
                GameState = Gstate.Game;
            }

            return(true);
        }
Ejemplo n.º 5
0
        public GameControl(Vector2 WindowSize)
        {
            // GState.Game loads the game
            // GState.Menu loads the menu
            GameState = Gstate.Menu;
            MyWumpus = new Wumpus(new Vector2(Room.thisSize.Center.X - 35, Room.thisSize.Center.Y - 35), "Wumpus2_Small");
            MyTrivia = new Trivia("Chemistry");
            MyCave = new Cave1("C:\\Users\\" + username + "\\Dropbox\\WumpusTest\\WumpusTest\\WumpusTestContent\\CaveFiles\\MapDataCave1.txt");
            MyPlayer = new Player(new Vector2(WindowSize.X / 2, WindowSize.Y / 2), "Player\\Player5", 0, 10, 0, 0, 3.5f);
            MyMap = new Map(MyCave.getTotalChambers());
            MySound = new Sound();

            MyUI = new GUI();
            GameDimensions = WindowSize;
        }
Ejemplo n.º 6
0
        public GameControl(Vector2 WindowSize)
        {
            // GState.Game loads the game
            // GState.Menu loads the menu
            GameState = Gstate.Menu;
            MyPlayer = new Player(new Vector2(WindowSize.X/2, WindowSize.Y/2), "Player\\Player2", 0, 10, 0, 0, 3.5f);
            MyMap = new Map();
            MyWumpus = new Wumpus(Vector2.Zero, "Wumpus2_Small");
            MyTrivia = new Trivia("Chemistry");
            //UNIVERSAL TEST:
            MyCave = new Cave1("C:\\Users\\" + username + "\\Dropbox\\WumpusTest\\WumpusTest\\WumpusTestContent\\CaveFiles\\MapDataCave1.txt");
            MySound = new Sound();

            MyUI = new GUI();
            GameDimensions = WindowSize;
        }
Ejemplo n.º 7
0
 public List <int> EndGame()
 {
     GameState = Gstate.EndGame;
     hs.saveHighScores(MyPlayer.getScore());
     return(hs.getMyList());
 }
Ejemplo n.º 8
0
 public void die()
 {
     GameState = Gstate.EndGame;
     // show endgame graphics
     // Call high score and display high score
 }
Ejemplo n.º 9
0
 public void die()
 {
     GameState = Gstate.EndGame;
     // show endgame graphics
     // Call high score and display high score
 }
Ejemplo n.º 10
0
        // When the user presses the "Start Game" button, the state of the game is set to 1 (in game).
        // This happens only when the user is NOT ALREADY in the game.
        public bool startGame()
        {
            if(GameState != Gstate.Game)
                GameState = Gstate.Game;

            return true;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// на доработку
        /// </summary>
        /// <param name="gs"></param>
        public void SetPhase(Gstate gs)
        {
            switch (gs) {
                case Gstate.CloseGame:
                    break;
                case Gstate.NewGame:
                    DrawProc = GameDraw;
                    break;
                case Gstate.OldGame:
                    DrawProc = GameDraw;
                    break;
                case Gstate.InGameMessage:
                    DrawProc = InGameMessageDraw;
                    break;
                case Gstate.MainMenu:
                    DrawProc = MainMenuDraw;
                    break;
                case Gstate.GenerationScreen:
                    DrawProc = DrawGMapGenRects;
                    break;
            }

            gstate = gs;
        }
Ejemplo n.º 12
0
    void init()
    {
        if (vertices.Length != segments)
        {
            vertices = new Vector3[segments];
        }
        qlist = new float[segments];
        for (int i = 0; i < segments; i++)
        {
            if (i == 0)
            {
                vertices[i] = new Vector3(xmin, ymin, 0);
            }
            else if (i == segments - 1)
            {
                vertices[i] = new Vector3(xmax, ymax, 0);
            }
            else
            {
                vertices[i]   = vertices[0];
                vertices[i].x = xmin + fw * (i) / (segments - 1);
            }
        }
        float  quality        = 0;   //current quality
        float  goalquality    = 100; //goal quality
        float  goaldisruption = 100; //goal disruption
        int    act            = 0;   // action index
        float  t         = 72000;    //current time
        float  interval  = 43200f / (segments - 1f);
        bool   pm        = true;
        Gstate gamestate = new Gstate();
        bool   asleep    = false;

        vactlist = new VertexActions[0];
        qlist[0] = 0;
        float eq        = 0;
        float eduration = 0;

        overall = 0;
        sp      = new int[0];
        int tos_iterator = 0;

        for (int i = 1; i < vertices.Length; i++)
        {
            t += interval;

            if (eduration > 0)
            {
                eduration -= interval;
                if (eduration <= 0)
                {
                    eq = 0;
                }
            }
            if (t >= 86400)
            {
                t -= 86400;
                pm = false;
            }
            bool added = false;
            while (true)
            {
                if (act >= trial.actions.Length)
                {
                    break;
                }
                if (pm)
                {
                    if (trial.actions[act].timestamp <= t && trial.actions[act].timestamp >= 72000 || (t + interval >= 86400 && trial.actions[act].timestamp < 86400 && trial.actions[act].timestamp > 72000))
                    {
                        if (!added)
                        {
                            added = true;
                            VertexActions[] temp = new VertexActions[vactlist.Length + 1];
                            for (int j = 0; j < vactlist.Length; j++)
                            {
                                temp[j] = vactlist[j];
                            }
                            temp[temp.Length - 1]               = new VertexActions();
                            temp[temp.Length - 1].actionlist    = new SleepLab.Action[1];
                            temp[temp.Length - 1].actionlist[0] = trial.actions[act];
                            vactlist = temp;
                        }
                        else
                        {
                            vactlist[vactlist.Length - 1].Add(trial.actions[act]);
                        }
                        gamestate.ApplyAction(trial.actions[act]);
                        if (trial.actions[act].iname == "Event")
                        {
                            eq        = trial.actions[act].eq;
                            eduration = trial.actions[act].eduration;
                        }
                        act++;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    if ((trial.actions[act].timestamp <= t) || (t + interval >= 28800 && t < 72000))
                    {
                        if (!added)
                        {
                            added = true;
                            VertexActions[] temp = new VertexActions[vactlist.Length + 1];
                            for (int j = 0; j < vactlist.Length; j++)
                            {
                                temp[j] = vactlist[j];
                            }
                            temp[temp.Length - 1]               = new VertexActions();
                            temp[temp.Length - 1].actionlist    = new SleepLab.Action[1];
                            temp[temp.Length - 1].actionlist[0] = trial.actions[act];
                            vactlist = temp;
                        }
                        else
                        {
                            vactlist[vactlist.Length - 1].Add(trial.actions[act]);
                        }
                        gamestate.ApplyAction(trial.actions[act]);
                        if (trial.actions[act].iname == "Event")
                        {
                            eq        = trial.actions[act].eq;
                            eduration = trial.actions[act].eduration;
                        }
                        act++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Vector2 rvalue = GetGoal(gamestate);
            goaldisruption = rvalue.x - eq;
            goalquality    = rvalue.y - eq;
            if (goalquality < 0)
            {
                goalquality = 0;
            }
            if (goaldisruption < 0)
            {
                goaldisruption = 0;
            }

            if (asleep)
            {
                quality = Mathf.MoveTowards(quality, goalquality, interval * speed);
            }
            else
            {
                quality = 0;
            }
            if (tos_iterator < trial.timeofsleep.Length)
            {
                if (t >= trial.timeofsleep[tos_iterator] && trial.timeofsleep[tos_iterator] >= 72000)
                {
                    float ctdelta = t;
                    if (t > 72000)
                    {
                        ctdelta -= 72000;
                    }
                    else if (t < 72000)
                    {
                        ctdelta += 14400;
                    }

                    float tsdelta = trial.timeofsleep[tos_iterator];
                    if (tsdelta > 72000)
                    {
                        tsdelta -= 72000;
                    }
                    else if (tsdelta < 72000)
                    {
                        tsdelta += 14400;
                    }

                    float idelta = Mathf.Abs(ctdelta - tsdelta);
                    if (!asleep)
                    {
                        idelta = Mathf.Abs(interval - idelta);
                    }
                    quality = Mathf.MoveTowards(quality, goalquality, idelta * speed);
                    asleep  = !asleep;
                    tos_iterator++;

                    int[] _sp = new int[sp.Length + 1];
                    for (int b = 0; b < sp.Length; b++)
                    {
                        _sp[b] = sp[b];
                    }
                    _sp[_sp.Length - 1] = i;
                    sp = _sp;
                }
                else if (t >= trial.timeofsleep[tos_iterator] && t < 72000 && trial.timeofsleep[tos_iterator] < 72000)
                {
                    float ctdelta = t;
                    if (t > 72000)
                    {
                        ctdelta -= 72000;
                    }
                    else if (t < 72000)
                    {
                        ctdelta += 14400;
                    }

                    float tsdelta = trial.timeofsleep[tos_iterator];
                    if (tsdelta > 72000)
                    {
                        tsdelta -= 72000;
                    }
                    else if (tsdelta < 72000)
                    {
                        tsdelta += 14400;
                    }

                    float idelta = Mathf.Abs(ctdelta - tsdelta);
                    if (!asleep)
                    {
                        idelta = Mathf.Abs(interval - idelta);
                    }
                    quality = Mathf.MoveTowards(quality, goalquality, idelta * speed);
                    asleep  = !asleep;
                    tos_iterator++;

                    int[] _sp = new int[sp.Length + 1];
                    for (int b = 0; b < sp.Length; b++)
                    {
                        _sp[b] = sp[b];
                    }
                    _sp[_sp.Length - 1] = i;
                    sp = _sp;
                }
            }

            vertices[i].y = ymin + fh * (quality / 100f);
            if (added)
            {
                vactlist[vactlist.Length - 1].position = new Vector2(vertices[i].x, vertices[i].y);
            }
            qlist[i] = Mathf.Round(quality);
            if (asleep)
            {
                overall += interval * quality / 100f;
            }
        }
    }
Ejemplo n.º 13
0
    Vector2 GetGoal(Gstate gs)
    {
        Vector2 result = new Vector2(100, 100);

        if (gs.tv)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.stereo1)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.stereo2)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.lamp1)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.lamp2)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.lamp3)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.laptop)
        {
            result.x -= 5;
            result.y -= 10;
        }

        if (gs.fan == 3)
        {
            result.x -= 5;
            result.y -= 10;
        }
        if (gs.fan == 2)
        {
            result.x -= 2.5f;
            result.y -= 6;
        }
        if (gs.fan == 1)
        {
        }
        if (gs.fan == 0)
        {
            result.x -= 1;
            result.y -= 2;
        }

        if (gs.beanbags[0])
        {
            result.x -= 4.5f;
        }
        if (gs.beanbags[1])
        {
            result.x -= 4.5f;
        }
        if (gs.boats[0])
        {
            result.x -= 4.5f;
        }
        if (gs.cars[0])
        {
            result.x -= 4.5f;
        }
        if (gs.drum)
        {
            result.x -= 4.5f;
        }
        if (gs.elephants[1])
        {
            result.x -= 4.5f;
        }
        if (gs.giraffe)
        {
            result.x -= 4.5f;
        }
        if (gs.guitar)
        {
            result.x -= 4.5f;
        }
        if (gs.makeup[1])
        {
            result.x -= 4.5f;
        }
        if (gs.airplane)
        {
            result.x -= 4.5f;
        }

        if (gs.bedcolor == 0 || gs.bedcolor == 2 || gs.bedcolor == 10)
        {
        }
        else if (gs.bedcolor == 5)
        {
            result.x -= 6;
            result.y -= 8;
        }
        else if (gs.bedcolor == 1)
        {
            result.x -= 3;
            result.y -= 4;
        }
        else
        {
            result.x -= 1.5f;
            result.y -= 2;
        }

        if (gs.wallcolor == 0 || gs.wallcolor == 2 || gs.wallcolor == 10)
        {
        }
        else if (gs.wallcolor == 5)
        {
            result.x -= 9;
            result.y -= 12;
        }
        else if (gs.wallcolor == 1)
        {
            result.x -= 4.5f;
            result.y -= 6;
        }
        else
        {
            result.x -= 2.25f;
            result.y -= 3;
        }

        return(result);
    }
Ejemplo n.º 14
0
 //public void DelayedFunction()
 //{
 //currentState = Gstate.Idle;
 //friendFollow.BackToIdle();
 //}
 public void BackToIdle()
 {
     friendFollow.BackToIdle();
     currentState = Gstate.Idle;
     Debug.Log("is Idle");
 }