コード例 #1
0
        public void throwViruses(Vector3 palm, Vector3 norm, Vector3 palmVel, float grab)
        {
            for (int i = 0; i < viruses.Count; i++)
            {
                Virus v = viruses[i];

                if (((palm - v.position).LengthSquared() < 4 && grab < .4f))
                {
                    if (palmVel.Z > 1)
                        v.awake = true;
                }
            }
        }
コード例 #2
0
        public void generateVirus(Virus reference, float off = 3f)
        {
            Random r = new Random(Environment.TickCount);
            Virus  v = new Virus(reference.type, reference.shape, reference.enterType, reference.exitType, this.position + Vector3.Normalize(new Vector3((float)r.NextDouble() - (float)r.NextDouble(), (float)r.NextDouble() - (float)r.NextDouble(), (float)r.NextDouble() - (float)r.NextDouble())) * off, Main.main.world);

            v.velocity        = Vector3.Normalize(v.position - this.position) * 10 + this.velocity;
            v.awake           = false;
            v.angularVelocity = new Vector3((float)r.NextDouble() * MathHelper.PiOver2) * .5f * this.angularVelocity;
            this.viruses.Add(v);
            if (this.viruses.Count > new Random().Next(5, 7))
            {
                if (reference.exitType == ExitType.Lysis)
                {
                    this.exploding = true;
                }
                else
                {
                    this.dying = true;
                }
            }
        }
コード例 #3
0
        protected override void Initialize()
        {
            leapInput             = new LeapHandler();
            world                 = new Sim.World();
            world.camera.position = new Vector3(0, 0, 0);
            world.camera.offset   = new Vector3(0, 0, 0);
            world.camera.mode     = CameraMode.Orbit;
            handCamera            = new Camera(new Vector2(screenWidth, screenHeight));
            handCamera.mode       = CameraMode.FirstPerson;
            handCamera.position   = new Vector3(0, 1, 10);
            handRenderer          = new Renderer();
            titleRenderer         = new Renderer();

            gameState = GameState.MainMenu;

            #region UI
            UI.Screen mainScreen = new UI.Screen(new UI.UDim2(0, 0, 0, 0), new UI.UDim2(1, 1, 0, 0));
            UI.Button start      = mainScreen.addButton(new UI.UDim2(.5f, 1, -100, -300), new UI.UDim2(0, 0, 200, 60), "Start");
            UI.Button exit       = mainScreen.addButton(new UI.UDim2(.5f, 1, -100, -200), new UI.UDim2(0, 0, 200, 60), "Exit");

            UI.Screen    constructionScreen = new UI.Screen(new UI.UDim2(0, 0, 0, 0), new UI.UDim2(1, 1, 0, 0), false);
            UI.Button    back         = constructionScreen.addButton(new UI.UDim2(.5f, 1, -100, -150), new UI.UDim2(0, 0, 200, 60), "Back");
            UI.RadioList entrymethods = constructionScreen.addRadioList(new UI.UDim2(0, 0f, 20, 125), new UI.UDim2(0, 0, 200, 60), "Entry Method", new List <UI.RadioListElement>()
            {
                new UI.RadioListElement()
                {
                    name = "Trojan Horse", detail = "Target cell unknowingly absorbes virus"
                },
                new UI.RadioListElement()
                {
                    name = "Ingestion", detail = "Target cell ingests virus"
                },
                new UI.RadioListElement()
                {
                    name = "Injection", detail = "Virus injects genetic material directly into target cell"
                }
            });
            UI.RadioList exitmethods = constructionScreen.addRadioList(new UI.UDim2(.5f, 0f, 0, 125), new UI.UDim2(0, 0, 200, 60), "Exit Method", new List <UI.RadioListElement>()
            {
                new UI.RadioListElement()
                {
                    name = "Lysis", detail = "Cell bursts and releases virus"
                },
                new UI.RadioListElement()
                {
                    name = "Pinch/Bud", detail = "Virus penetrates through cell membrane"
                }
            });
            UI.RadioList shapes = constructionScreen.addRadioList(new UI.UDim2(.5f, 0f, 0, 425), new UI.UDim2(0, 0, 200, 60), "Shape", new List <UI.RadioListElement>()
            {
                new UI.RadioListElement()
                {
                    name = "Spherical", detail = "", onSelected = () =>
                    {
                        UI.RadioListElement el = entrymethods.items[2];
                        el.disabled            = true;
                        el.detail             = "Not compatible with injection!";
                        entrymethods.items[2] = el;
                    }
                },
                new UI.RadioListElement()
                {
                    name = "Complex", detail = "", onSelected = () => {
                        UI.RadioListElement el = entrymethods.items[2];
                        el.disabled            = false;
                        el.detail             = "Virus injects genetic material directly into target cell";
                        entrymethods.items[2] = el;
                    }
                }
            });
            UI.RadioList type = constructionScreen.addRadioList(new UI.UDim2(0, 0f, 20, 425), new UI.UDim2(0, 0, 200, 60), "Type", new List <UI.RadioListElement>()
            {
                new UI.RadioListElement()
                {
                    name = "RNA Hijack", detail = "Injection of RNA to hijack nucleus"
                },
                new UI.RadioListElement()
                {
                    name = "Lysogenic Cycle", detail = "RNA fuses with DNA of cell"
                }
            });
            UI.Button begin = constructionScreen.addButton(new UI.UDim2(.5f, 1, -100, -250), new UI.UDim2(0, 0, 200, 60), "Start");

            constructionScreen.buttonColor = Color.CadetBlue;
            mainScreen.buttonColor         = Color.CadetBlue;

            begin.onClick += () =>
            {
                if (shapes.selected + entrymethods.selected + type.selected + exitmethods.selected < 0)
                {
                    //Debug.print("hey, dumbass, you forgot one");
                }
                else
                {
                    mainScreen.visible         = false;
                    constructionScreen.visible = false;
                    gameState = GameState.InGame;

                    Sim.VirusShape vshape = shapes.selected == 0 ? Sim.VirusShape.Icosahedral : Sim.VirusShape.Complex;
                    Sim.EnterType  entype = (Sim.EnterType)entrymethods.selected;
                    Sim.ExitType   extype = (Sim.ExitType)exitmethods.selected;
                    Sim.VirusType  vtype  = (Sim.VirusType)type.selected;
                    Sim.Virus      virus  = new Sim.Virus(vtype, vshape, entype, extype, Vector3.Zero, world);
                    virus.cameraSubject = true;

                    world.generateWorld();
                }
            };

            start.onClick += () =>
            {
                mainScreen.visible         = false;
                constructionScreen.visible = true;
                titleRenderer.setModel(null, Microsoft.Xna.Framework.Matrix.Identity);
            };
            exit.onClick += () =>
            {
                this.Exit();
            };
            back.onClick += () =>
            {
                mainScreen.visible         = true;
                constructionScreen.visible = false;
                titleRenderer.setModel(titletext, Microsoft.Xna.Framework.Matrix.Identity);
            };
            #endregion
            base.Initialize();
        }