Exemplo n.º 1
0
        public override void Intersect(InteractiveModel interactive)
        {
            if(this==interactive || !interactive.GetType().IsSubclassOf(typeof(Unit)))
            { return ; }

                         if (this.model.Spheres[0].Intersects(interactive.Model.BoundingSphere))
                         {
                             interactive.Hp -= (int)1;
                             ((Unit)interactive).LifeBar.LifeLength = ((Unit)interactive).LifeBar.LifeLength - ((Unit)interactive).LifeBar.LifeLength * ((float)5 / interactive.MaxHp);
                         }
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            ///interface --------------------------------------------------------------------------------
            if (control.selectedObject != null)
            {
                selectedModel = control.selectedObject;
                description = selectedModel.ToString();

                if (selectedModel.GetType() == (typeof(BuildingPlace)))
                {
                    buildMenuON = true;

                }
                else if (selectedModel.GetType() != typeof(BuildingPlace) && selectedModel.GetType().IsSubclassOf(typeof(Building)))
                {
                    description = selectedModel.ToString();
                    if (selectedModel.GetType() == typeof(HyacyntFarm))
                    {

                        hyacyntFarmOn = true;
                        dicentraFarmOn = false;
                        mainBuildingOn = false;
                        buildMenuON = false;
                        unitMenuON = false;
                        beetleBuildingOn=false;
                        grassHopperBuildingOn=false;
                        helidoniumFarmOn = false;

                    }
                    else if (selectedModel.GetType() == typeof(DicentraFarm))
                    {
                        hyacyntFarmOn = false;
                        dicentraFarmOn = true;
                        mainBuildingOn = false;
                        buildMenuON = false;
                        unitMenuON = false;
                        helidoniumFarmOn = false;

                    }
                    else   if (selectedModel.GetType() == typeof(BeetleBuilding))
                    {
                        hyacyntFarmOn = false;
                        dicentraFarmOn = false;
                        mainBuildingOn = false;
                        buildMenuON = false;
                        unitMenuON = false;
                        beetleBuildingOn = true;
                        grassHopperBuildingOn = false;
                        helidoniumFarmOn = false;

                    }
                    else if (selectedModel.GetType() == typeof(GrassHopperBuilding))
                    {
                        hyacyntFarmOn = false;
                        dicentraFarmOn = false;
                        mainBuildingOn = false;
                        buildMenuON = false;
                        unitMenuON = false;
                        beetleBuildingOn = false;
                        grassHopperBuildingOn = true;
                        helidoniumFarmOn = false;

                    }
                    else if (selectedModel.GetType() == typeof(ChelidoniumFarm))
                    {
                        hyacyntFarmOn = false;
                        dicentraFarmOn = false;
                        mainBuildingOn = false;
                        buildMenuON = false;
                        unitMenuON = false;
                        helidoniumFarmOn = true;
                    }
                    else
                    {
                        hyacyntFarmOn = false;
                        dicentraFarmOn = false;
                        mainBuildingOn = false;
                        buildMenuON = false;
                        unitMenuON = false;
                        helidoniumFarmOn = false;

                    }

                }

            }
            else
            {
                description = "";
            }
            if (control.SelectedModels.Count > 0)
            {
                selectedModels = control.SelectedModels;
            }

            // get elapsed frame time in seconds
            frame_time = gameTime.ElapsedGameTime.Milliseconds / 1000.0;

            // update mouse variables
            MouseState mouse_state = Mouse.GetState();
            mx = mouse_state.X;
            my = mouse_state.Y;
            prev_mpressed = mpressed;
            mpressed = mouse_state.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;

            update_buttons();  //--------------------------------------------------------------------------------------------------------------------------------- uncomment and fix
        }