Ejemplo n.º 1
0
        public Ghost(float x, float y, bool impostor)
        {
            X = x;
            Y = y;
            Impostor = impostor;

            mySprite = new Spritemap<string>(Assets.GFX_GHOST_SHEET, 22, 20);
            mySprite.Add("idle", new int[] { 0, 1, 2, 3 }, new float[] { 8f });
            mySprite.Add("distort", new int[] { 8, 9, 10 }, new float[] { 1f });
            mySprite.Play("idle");
            mySprite.CenterOrigin();

            mySpeed = new Speed(2);

            Image ghostShadow = new Image(Assets.GFX_SHADOW);
            ghostShadow.CenterOrigin();
            ghostShadow.Alpha = 0.5f;
            AddGraphic(ghostShadow);
            AddGraphic(mySprite);

            AddCollider(new BoxCollider(22, 20, 0));
            Collider.CenterOrigin();
            Layer = 5;

            if(!impostor)
            {
                myController = Global.theController;
            }
        }
Ejemplo n.º 2
0
        public void HandleInput()
        {
            myController = Global.thePlayerSession.GetController<ControllerXbox360>();
            Vector2 moveDelta = new Vector2();
            if (!Dead)
            {

                if (InsideShip)
                {
                    moveDelta.X = myController.LeftStick.X * 0.1f;
                    moveDelta.Y = myController.LeftStick.Y * 0.1f;
                }

                // if LB down, render radial menu
                RenderRadial = myController.LB.Down;

                // if use item key is pressed, use an item -- select from radial if radial is used
                if (myController.X.Pressed)
                {
                    // Check for radial, select if it's on.
                    if (RenderRadial)
                    {
                        // get crosshair angle
                        Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                        directionToXHair.Normalize();
                        float AtanResult = (float)Math.Atan2(directionToXHair.X, directionToXHair.Y);
                        if (AtanResult < 0)
                        {
                            AtanResult += 2 * (float)Math.PI;
                        }
                        float Ang = MathHelper.ToDegrees(AtanResult);
                        Otter.Debugger.Instance.Log(Ang);
                        // Get closest to ang
                        float res = Ang / 360.0f;
                        Otter.Debugger.Instance.Log(res * 10);
                        int index = (int)Math.Round(res * 10);

                        if (index == 10)
                        {
                            index = 0;
                        }
                        SelectedItem = index;

                    }
                    else
                    {
                        // use the currently-held item
                        switch (SelectedItem)
                        {
                            case 0:
                                // Hands - Used to inspect an object.
                                // Check for inspection target nearby, inspecting if necessary.
                                if (crossHair.Overlap(crossHair.X, crossHair.Y, 6))
                                {
                                    //machine, display text in box.
                                    Collider target = crossHair.Collide(crossHair.X, crossHair.Y, 6);
                                    if (target.Entity.GetType().Name == "Machine")
                                    {
                                        Machine theMachine = (Machine)target.Entity;
                                        Global.ResetBox = true;
                                        Global.MsgString = theMachine.Name + ":\n" + theMachine.Description;
                                        if (theMachine.Status == 2)
                                        {
                                            Global.MsgString += "\n" + theMachine.FlavBroke;
                                        }
                                        if (theMachine.Status == 3)
                                        {
                                            Global.MsgString += "\n" + theMachine.FlavFixing;
                                        }

                                        inspectMachine = theMachine;
                                        RenderDetail = true;
                                        StartInspect = Global.theGame.Timer;
                                    }
                                }
                                // Check for inspection target nearby, inspecting if necessary.
                                if (crossHair.Overlap(crossHair.X, crossHair.Y, 10))
                                {
                                    //machine, display text in box.
                                    Collider target = crossHair.Collide(crossHair.X, crossHair.Y, 10);
                                    if (target.Entity.GetType().Name == "Airlock")
                                    {
                                        Airlock theMachine = (Airlock)target.Entity;
                                        if (!theMachine.Open)
                                        {
                                            theMachine.DoorOpen();
                                            Global.NewWords("Opening Airlock...");
                                        }
                                        if (theMachine.Open)
                                        {
                                            theMachine.DoorClose();
                                            Global.NewWords("Closing Airlock...");
                                        }
                                    }
                                }
                                // Pick up other items if there is room.
                                if (crossHair.Overlap(crossHair.X, crossHair.Y, 1))
                                {
                                    Collider target = crossHair.Collide(crossHair.X, crossHair.Y, 1);
                                    if (target.Entity.GetType().Name == "Item")
                                    {
                                        Item theItem = (Item)target.Entity;

                                        // get item based on type
                                        switch (theItem.itemType)
                                        {
                                            case 1:
                                                if (Boots < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    Global.NewWords("You grab the boots.\nYou wear the boots.\nThey look ridiculous.");
                                                    Boots = 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 2:
                                                if (Circuit < 5)
                                                {
                                                    theItem.RemoveSelf();
                                                    Circuit += 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 3:
                                                if (FloorTile < 5)
                                                {
                                                    theItem.RemoveSelf();
                                                    FloorTile += 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 4:
                                                if (Wrench < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    Global.NewWords("You picked up the wrench.\nUse this to fix machines!");
                                                    Wrench = 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 5:
                                                if (Battery < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    Battery = 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 6:
                                                if (Donut < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    Donut = 1;
                                                    Global.NewWords("You get the donut-shaped nutriment\nsupplement. It's got real icing!\nThat's the only real thing about it.");
                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 7:
                                                if (Crisps < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    Crisps = 1;
                                                    Global.NewWords("You pick up the 'Golden Wonger'\nbrand potato crisps. It says\n'potabo chisps' on the packet.\nNothing to worry about?");
                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 8:
                                                if (FireExtinguisher < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    FireExtinguisher = 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                            case 9:
                                                if (O2Tank < 1)
                                                {
                                                    theItem.RemoveSelf();
                                                    O2Tank = 1;

                                                }
                                                else
                                                {
                                                    //can't pick up
                                                }
                                                break;
                                        }

                                    }

                                }

                                break;
                            case 1:
                                if (Boots < 1)
                                {
                                    Global.NewWords("You aren't wearing your boots\nanymore. Your socks are terrible.");
                                }
                                else
                                {
                                    Global.NewWords("You touch your toes.\nIt's good to stay in shape.\nBack to work!");
                                }

                                break;
                            case 2:
                                if (Circuit > 0)
                                {
                                    Global.NewWords("You hug the circuit board.\n It feels better.");
                                }
                                break;
                            case 3:
                                if (FloorTile > 0)
                                {
                                    Global.NewWords("These tiles weren't designed to\n be torn out of the flooring.");
                                }
                                break;
                            case 6:
                                if ( Donut > 0)
                                {
                                    Donut = 0;
                                    Global.NewWords("You consume the donut-like object.\nIt fills you with purpose.");
                                }
                                break;
                            case 7:
                                if ( Crisps > 0)
                                {
                                    Crisps = 0;
                                    Dead = true;
                                    Global.NewWords("Golden Wongers are a kind of \ngalactic shapeshifting parasite.\nYou died.\n'Potabo chisps'? Really?\n[Press P to Restart]");
                                }
                                break;
                            case 4:
                                if (Wrench < 1)
                                {
                                    break;
                                }

                                // wrench, fix things
                                // Check for inspection target nearby, inspecting if necessary.
                                if (crossHair.Overlap(crossHair.X, crossHair.Y, 6))
                                {
                                    //machine, display text in box.
                                    Collider target = crossHair.Collide(crossHair.X, crossHair.Y, 6);
                                    if (target.Entity.GetType().Name == "Machine")
                                    {
                                        Machine theMachine = (Machine)target.Entity;
                                        if (theMachine.Status == 2)
                                        {
                                            theMachine.BeginFix();
                                            if (theMachine.Name == "Vending Machine")
                                            {
                                                Global.NewWords("You set the machine to reboot.\nIt'll vend itself some new glass.");
                                            }
                                            if (theMachine.Name == "Computer")
                                            {
                                                Global.NewWords("It was just a screensaver.\nYou idiot.");
                                            }
                                        }
                                        else
                                        {
                                            Global.NewWords("If it ain't broke, don't fix it.");
                                        }

                                        inspectMachine = theMachine;
                                        RenderDetail = true;
                                        StartInspect = Global.theGame.Timer;

                                    }
                                }
                                else
                                {
                                    Global.NewWords("You swing the wrench around.\n\nLike an idiot.");
                                }
                                break;

                            default:
                                //nada
                                break;
                        }
                    }

                }

                // Item is thrown away or hands strike object
                if (myController.B.Pressed)
                {
                    switch (SelectedItem)
                    {
                        case 0:
                            // Percussive force! Wham!
                            // Check for machine, shorten break  time.
                            // Chance to fix?
                            // If vending machine, chance to vend item instead of hurting it. 80% chance.

                            break;
                        case 1:
                            // Take off your hat, kick off your shoes...
                            if (Boots > 0)
                            {
                                Boots = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                                Global.NewWords("You kick off your boots.\nIt's pretty slidy in your socks.");

                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 2:
                            // Take off your hat, kick off your shoes...
                            if (Circuit > 0)
                            {
                                Circuit -= 1;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 3:
                            // Take off your hat, kick off your shoes...
                            if (FloorTile > 0)
                            {
                                FloorTile -= 1;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 4:
                            // Take off your hat, kick off your shoes...
                            if (Wrench > 0)
                            {
                                Wrench = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                                Global.NewWords("You throw away your only means\nof survival.");
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 5:
                            // Take off your hat, kick off your shoes...
                            if (Battery > 0)
                            {
                                Battery = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 6:
                            // Take off your hat, kick off your shoes...
                            if (Donut > 0)
                            {
                                Donut = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                                Global.NewWords("You throw the donut-type object\naway. It shines like plastic.");
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 7:
                            // Take off your hat, kick off your shoes...
                            if (Crisps > 0)
                            {
                                Crisps = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                                Global.NewWords("You toss away the 'chisps'.\nNik-Naks are better anyway.");
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 8:
                            // Take off your hat, kick off your shoes...
                            if (FireExtinguisher > 0)
                            {
                                FireExtinguisher = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        case 9:
                            // Take off your hat, kick off your shoes...
                            if (O2Tank > 0)
                            {
                                O2Tank = 0;
                                Item newItem = new Item(X, Y, SelectedItem);
                                this.Scene.Add(newItem);
                                Vector2 directionToXHair = new Vector2(crossHair.X - X, crossHair.Y - Y);
                                directionToXHair.Normalize();
                                newItem.Throw(directionToXHair);
                                if (!InsideShip)
                                {
                                    mySpeed.X = -directionToXHair.X;
                                    mySpeed.Y = -directionToXHair.Y;
                                }
                                SelectedItem = 0;
                            }
                            // ... i know you ain't goin anywhere
                            break;
                        default:
                            break;
                    }
                }

            }
            MoveInDirection(moveDelta);
        }