public Dog(mouseHelp mouse, AppDJ appDJ)
        {
            this.appDJ = appDJ;
            this.mouse = mouse;
            screenHeight = 480;
            screenWidth = 800;

            fetch = new Fetch(this, this.mouse, this.appDJ);
            water = new Water(this, this.mouse, this.appDJ);
            food = new Food(this, this.mouse, this.appDJ);
            tug = new Tug(this, this.mouse, this.appDJ);

            statThirst = 1.0f;
            statHygiene = 1.0f;
            statHunger = 1.0f;
            statEntertainment = 1.0f;
            statHappiness = 1.0f;
            myActivity = activity.dogIdle;
            myAnimate = animate.dogSitting;
            aniX = 0;
            aniY = 0;
            myFPS = 0;
            FPS = 12;
            returnHome = false;
            tugBool = false;

            dogX = (int)((float)screenWidth * .51);
            dogY = (int)((float)screenHeight * .54);
            dogZ = 0.5f;
            dogScale = 1.0f;
            dogRec = new Rectangle(0, 0, 200, 200);
            dogRot = 0.0f;
            origin = new Vector2(dogX, dogY);
            dogPos = new Vector2(dogX, dogY);
            returnSpeedX = 2;
            returnSpeedY = 1;
            returnSpeedS = .005f;
        }
Esempio n. 2
0
 public Chronic(string name, Water water, Light light, Food food)
     : this(name)
 {
     Water = water;
     Light = light;
     Food = food;
 }
Esempio n. 3
0
    public override void OnTriggerExit(Collider coll)
    {
        base.OnTriggerExit(coll);

        if (inwater!=Water.nullWater && inwater==coll.gameObject.GetComponent<Water>())
            inwater = Water.nullWater;
    }
    // Actual initialization code.  Can be called multiple times, and the initialization is propagated down
    public void Generate(int width, int height)
    {
        water = gameObject.GetComponent<Water>();
        water.Generate(width, height);

        inputForceType = SquareForce;
    }
 void Start()
 {
     water = this.GetComponent<Water>();
     camTransform = Camera.main.transform;
     thisTransform = this.transform;
     StartCoroutine(TryDisable());
     ChangeToQualityLevel(PlayerPrefs.GetInt("QualityLevel", 0));
 }
Esempio n. 6
0
    public override void OnTriggerEnter(Collider coll)
    {
        base.OnTriggerEnter(coll);

        Water tempWater = coll.gameObject.GetComponent<Water>();
        if (inwater==Water.nullWater && tempWater!=null)
            inwater = tempWater;
    }
Esempio n. 7
0
 public Beer(List<Hops> hops, Malt malt, Barley barley, Water water, Yeast yeast, List<Extras> extras )
 {
     this.hops = hops;
     this.malt = malt;
     this.barley = barley;
     base.water = water;
     this.yeast = yeast;
     this.extras = extras;
 }
        public void Execute()
        {
            if (water == null)
            {
                water = new Water(this.height, parent, app);
            }
            parent.Add(water);

            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (water.Node != null)
            {
                water.Node.Select();
            }
        }
        public Scene LoadScene()
        {
            using (Logger.EnterTimingStage("Loading scene"))
             {
            Logger.Print("Switching working directory to GTA folder");
            System.Environment.CurrentDirectory = Config.Instance.GTAFolderPath;

            var gtaVersion = GetGtaVersion();
            if (gtaVersion == GtaVersion.SanAndreas)
               Utils.TerminateWithError("GTA San Andreas is not supported");

            var water = new Water(gtaVersion);
            var sceneObjectsLoader = new SceneObjectsLoader(gtaVersion);
            var sceneObjects = sceneObjectsLoader.LoadScene();
            TexturesStorage.Instance.Reset();
            var scene = CreateScene(sceneObjects);
            scene.Water = water;
            GC.Collect();
            return scene;
             }
        }
Esempio n. 10
0
    public void OnWillRenderObject()
    {
        if (!base.get_enabled() || !base.get_renderer() || !base.get_renderer().get_sharedMaterial() || !base.get_renderer().get_enabled())
        {
            return;
        }
        Camera current = Camera.get_current();

        if (!current)
        {
            return;
        }
        if (Water.s_InsideWater)
        {
            return;
        }
        Water.s_InsideWater         = true;
        this.m_HardwareWaterSupport = this.FindHardwareWaterSupport();
        Water.WaterMode waterMode = this.GetWaterMode();
        Camera          camera;
        Camera          camera2;

        this.CreateWaterObjects(current, out camera, out camera2);
        Vector3 position        = base.get_transform().get_position();
        Vector3 up              = base.get_transform().get_up();
        int     pixelLightCount = QualitySettings.get_pixelLightCount();

        if (this.m_DisablePixelLights)
        {
            QualitySettings.set_pixelLightCount(0);
        }
        this.UpdateCameraModes(current, camera);
        this.UpdateCameraModes(current, camera2);
        if (waterMode >= Water.WaterMode.Reflective)
        {
            float     num   = -Vector3.Dot(up, position) - this.m_ClipPlaneOffset;
            Vector4   plane = new Vector4(up.x, up.y, up.z, num);
            Matrix4x4 zero  = Matrix4x4.get_zero();
            Water.CalculateReflectionMatrix(ref zero, plane);
            Vector3 position2 = current.get_transform().get_position();
            Vector3 position3 = zero.MultiplyPoint(position2);
            camera.set_worldToCameraMatrix(current.get_worldToCameraMatrix() * zero);
            Vector4   clipPlane        = this.CameraSpacePlane(camera, position, up, 1f);
            Matrix4x4 projectionMatrix = current.get_projectionMatrix();
            Water.CalculateObliqueMatrix(ref projectionMatrix, clipPlane);
            camera.set_projectionMatrix(projectionMatrix);
            camera.set_cullingMask(-17 & this.m_ReflectLayers.get_value());
            camera.set_targetTexture(this.m_ReflectionTexture);
            GL.SetRevertBackfacing(true);
            camera.get_transform().set_position(position3);
            Vector3 eulerAngles = current.get_transform().get_eulerAngles();
            camera.get_transform().set_eulerAngles(new Vector3(0f, eulerAngles.y, eulerAngles.z));
            camera.Render();
            camera.get_transform().set_position(position2);
            GL.SetRevertBackfacing(false);
            base.get_renderer().get_sharedMaterial().SetTexture("_ReflectionTex", this.m_ReflectionTexture);
        }
        if (waterMode >= Water.WaterMode.Refractive)
        {
            camera2.set_worldToCameraMatrix(current.get_worldToCameraMatrix());
            Vector4   clipPlane2        = this.CameraSpacePlane(camera2, position, up, -1f);
            Matrix4x4 projectionMatrix2 = current.get_projectionMatrix();
            Water.CalculateObliqueMatrix(ref projectionMatrix2, clipPlane2);
            camera2.set_projectionMatrix(projectionMatrix2);
            camera2.set_cullingMask(-17 & this.m_RefractLayers.get_value());
            camera2.set_targetTexture(this.m_RefractionTexture);
            camera2.get_transform().set_position(current.get_transform().get_position());
            camera2.get_transform().set_rotation(current.get_transform().get_rotation());
            camera2.Render();
            base.get_renderer().get_sharedMaterial().SetTexture("_RefractionTex", this.m_RefractionTexture);
        }
        if (this.m_DisablePixelLights)
        {
            QualitySettings.set_pixelLightCount(pixelLightCount);
        }
        switch (waterMode)
        {
        case Water.WaterMode.Simple:
            Shader.EnableKeyword("WATER_SIMPLE");
            Shader.DisableKeyword("WATER_REFLECTIVE");
            Shader.DisableKeyword("WATER_REFRACTIVE");
            break;

        case Water.WaterMode.Reflective:
            Shader.DisableKeyword("WATER_SIMPLE");
            Shader.EnableKeyword("WATER_REFLECTIVE");
            Shader.DisableKeyword("WATER_REFRACTIVE");
            break;

        case Water.WaterMode.Refractive:
            Shader.DisableKeyword("WATER_SIMPLE");
            Shader.DisableKeyword("WATER_REFLECTIVE");
            Shader.EnableKeyword("WATER_REFRACTIVE");
            break;
        }
        Water.s_InsideWater = false;
    }
Esempio n. 11
0
        public void OnAddOrderItemButtonClicked(object sender, RoutedEventArgs e)
        {
            var orderControl = this.FindAncestor <OrderControl>();

            if (DataContext is Order order)
            {
                if (sender is Button button)
                {
                    IOrderItem       item;
                    FrameworkElement screen = null;
                    switch (button.Tag)
                    {
                    //cases for entrees
                    case "CowpokeChili":

                        item               = new CowpokeChili();
                        screen             = new CowpokeChiliCustomization();
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "AngryChicken":

                        item               = new AngryChicken();
                        screen             = new AngryChickenCustomization();
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "DakotaDoubleBurger":

                        item               = new DakotaDoubleBurger();
                        screen             = new DakotaDoubleBurgerCustomization();
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "PecosPulledPork":

                        item               = new PecosPulledPork();
                        screen             = new PecosPulledPorkCustomization();
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "TrailBurger":

                        item               = new TrailBurger();
                        screen             = new TrailBurgerCustomization();
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "TexasTripleBurger":

                        item               = new TexasTripleBurger();
                        screen             = new TexasTripleBurgerCustomization();
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    // No screenswap is needed as the Ribs have no special instructions
                    case "RustlersRibs":

                        item = new RustlersRibs();
                        order.Add(item);
                        break;


                    // Separator for Sides

                    case "BakedBeans":
                        item               = new BakedBeans();
                        screen             = new SizeCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "ChiliCheeseFries":
                        item               = new ChiliCheeseFries();
                        screen             = new SizeCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "CornDodgers":
                        item               = new CornDodgers();
                        screen             = new SizeCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "PanDeCampo":
                        item               = new PanDeCampo();
                        screen             = new SizeCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    // And finally drinks

                    case "Water":
                        item               = new Water();
                        screen             = new WaterCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "JerkedSoda":
                        item               = new JerkedSoda();
                        screen             = new JerkedSodaCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "CowboyCoffee":
                        item               = new CowboyCoffee();
                        screen             = new CowboyCoffeeCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;

                    case "TexasTea":
                        item               = new TexasTea();
                        screen             = new TexasTeaCustomization(DataContext);
                        screen.DataContext = item;
                        order.Add(item);
                        orderControl?.SwapScreen(screen);
                        break;
                    }
                }
            }
        }
Esempio n. 12
0
 public WaterTileSpectrum(WindWaves windWaves, int index)
 {
     this.windWaves = windWaves;
     this.water     = windWaves.GetComponent <Water>();
     this.tileIndex = index;
 }
Esempio n. 13
0
        public static MyTuple <Vector3D, float, float, float> GetPhysicalData(long ID)
        {
            Water Water = WaterMod.Static.Waters[ID];

            return(new MyTuple <Vector3D, float, float, float>(Water.position, Water.radius, Water.radius - Water.waveHeight - Water.tideHeight, Water.radius + Water.waveHeight + Water.tideHeight));
        }
        // Quality improvement algorithm.
        private void AdjustQuality(Water water, Light light, Food food)
        {
            // Plant has to be very healthy
            if (Health > 50)
            {
                // Always get some quality improvement.
                if (water == Water && light == Light)
                {
                    Quality *= 1.01;

                    if (food == Food.Low)
                        Quality *= 1.01;

                    else if (food == Food.Medium)
                        Quality *= 1.02;

                    else if (food == Food.High)
                        Quality *= 1.03;
                }
            }
        }
Esempio n. 15
0
        public void ShouldBeIcedByDefault()
        {
            var water = new Water();

            Assert.True(water.Ice);
        }
Esempio n. 16
0
    IEnumerator ProceduralLocal()
    {
        msg.Stop(Job.StartProcedural);
        msg.Start(Job.ProceduralPreparation);
        SimpleClient.jobStatus[jobNumber] = msg;

        this.transform.position = TilePosition - new Vector3((float)TileManager.TileWidth * (float)TileManager.Scaling / 2f, 0f, (float)TileManager.TileWidth * (float)TileManager.Scaling / 2f);
        terrain = this.gameObject.GetOrAddComponent <Terrain>();
        tC      = this.gameObject.GetOrAddComponent <TerrainCollider>();

        Building.Clear();
        Intersection.Clear();
        Street.Clear();
        Water.Clear();
        River.Clear();
        Bridge.Clear();

        unusedWays.Clear();
        streets.Clear();

        streetPolygons.Clear();

        msg.Stop(Job.ProceduralPreparation);

        #region LOD0
        if (lOD == 0)
        {
            Console.AddMessage("Procedural lod 0");
            Debug.Log("Procedural lod 0");
            #region terrain
            TerrainData terrainData = new TerrainData();

            //HeightMap
            terrainData.heightmapResolution = 257;
            float[,] heights = new float[257, 257];
            for (int x = 0; x < heights.GetLength(0); x++)
            {
                for (int y = 0; y < heights.GetLength(1); y++)
                {
                    heights[x, y] = 1f;
                }
            }

            terrainData.SetHeights(0, 0, heights);
            terrainData.size = new Vector3((float)TileManager.TileWidth * (float)TileManager.Scaling, 10f, (float)TileManager.TileWidth * (float)TileManager.Scaling);

            ////SplatPrototypes
            //SplatPrototype[] splatPrototypes = new SplatPrototype[1];
            //splatPrototypes[0] = new SplatPrototype();
            ////splatPrototypes[0].texture = (Texture2D)Resources.Load("Textures/White1px");
            //splatPrototypes[0].texture = (Texture2D)Resources.Load("Textures/Terrain/Grass (Hill)");

            //terrainData.splatPrototypes = splatPrototypes;

            terrain.terrainData = terrainData;
            tC.terrainData      = terrainData;
            #endregion terrain
            #region mesh
            TileMesh.Clear();

            Vertex[] tileQuadVertices = new Vertex[4];
            tileQuadVertices[0] = new Vertex(new Vector3((float)(-TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(-TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);
            tileQuadVertices[1] = new Vertex(new Vector3((float)(-TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);
            tileQuadVertices[2] = new Vertex(new Vector3((float)(TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);
            tileQuadVertices[3] = new Vertex(new Vector3((float)(TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(-TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);

            new Quad(tileQuadVertices, TileMesh, MaterialManager.GetMaterial("diffuseBrown"));

            TileMesh.FillMeshDivideMaterialsKeepMeshStructure(transform, true);
            #endregion
            Debug.Log("Procedural lod 0 - Done");
        }
        #endregion

        #region LOD5
        if (lOD == 5)
        {
            msg.Start(Job.CreateTerrain);
            SimpleClient.jobStatus[jobNumber] = msg;

            #region terrain
            if (terrain.terrainData == null)
            {
                terrain.terrainData = new TerrainData();
            }
            //HeightMap
            terrain.terrainData.heightmapResolution = 257;
            terrain.terrainData.alphamapResolution  = 257;

            float height = 0f;

            terrain.terrainData.SetHeights(0, 0, SRTMHeightProvider.GetInterpolatedTerrain(this.Query.BoundingBox, out height));
            terrain.terrainData.size = new Vector3((float)TileManager.TileWidth * (float)TileManager.Scaling, height, (float)TileManager.TileWidth * (float)TileManager.Scaling);

            tC.terrainData = terrain.terrainData;

            msg.Stop(Job.CreateTerrain);
            #endregion terrain
            #region mesh
            msg.Start(Job.MeshPreparation);
            SimpleClient.jobStatus[jobNumber] = msg;
            TileMesh.Clear();

            if (BackgroundMesh != null)
            {
                BackgroundMesh.Clear();
            }
            else
            {
                BackgroundMesh = new ModularMesh(TileMesh, "BackgroundMesh");
            }

            if (BuildingMesh != null)
            {
                BuildingMesh.Clear();
            }
            else
            {
                BuildingMesh = new ModularMesh(TileMesh, "BuildingMesh");
            }

            if (StreetMesh != null)
            {
                StreetMesh.Clear();
            }
            else
            {
                StreetMesh = new ModularMesh(TileMesh, "StreetMesh");
            }

            if (OtherMesh != null)
            {
                OtherMesh.Clear();
            }
            else
            {
                OtherMesh = new ModularMesh(TileMesh, "OtherMesh");
            }

            msg.Stop(Job.MeshPreparation);

            msg.Start(Job.TileQuad);
            SimpleClient.jobStatus[jobNumber] = msg;

            Vertex[] tileQuadVertices = new Vertex[4];
            tileQuadVertices[0] = new Vertex(new Vector3((float)(-TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(-TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);
            tileQuadVertices[1] = new Vertex(new Vector3((float)(-TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);
            tileQuadVertices[2] = new Vertex(new Vector3((float)(TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);
            tileQuadVertices[3] = new Vertex(new Vector3((float)(TileManager.TileWidth * TileManager.Scaling / 2d), 0f, (float)(-TileManager.TileWidth * TileManager.Scaling / 2d)) + TilePosition);

            new Quad(tileQuadVertices, BackgroundMesh, MaterialManager.GetMaterial("diffuseBlack"));
            msg.Stop(Job.TileQuad);


            yield return(null);

            msg.Start(Job.River);
            SimpleClient.jobStatus[jobNumber] = msg;

            //Create Domain Objects
            ///Relations
            foreach (KeyValuePair <long, OSMRelation> kV in Query.OSM.relations)
            {
                OSMRelation relation = kV.Value;

                River.TryCreateFromOSM(relation, this);
                yield return(null);
            }
            msg.Stop(Job.River);

            msg.Start(Job.Ways);
            SimpleClient.jobStatus[jobNumber] = msg;

            ///Ways
            foreach (KeyValuePair <long, OSMWay> kV in Query.OSM.ways)
            {
                OSMWay way = kV.Value;

                if (!way.FirstInBounds(Query.BoundingBox, Query.OSM))
                {
                    continue;
                }

                if (!Building.TryCreateFromOSM(way, this))
                {
                    if (!Intersection.TryCreateFromOSM(way, this))
                    {
                        if (!Water.TryCreateFromOSM(way, this))
                        {
                        }
                    }
                }

                yield return(null);
            }
            msg.Stop(Job.Ways);

            //Nodes!?
            //foreach (KeyValuePair<long, OSMNode> kV in Query.OSM.nodes)
            //{
            //    OSMNode node = kV.Value;
            //    TrafficSignal.TryCreateFromOSM(node, this);
            //}

            //Debug.Log("CreateStreets");
            ////Create Streets (and Bridges)
            //Street.CreateStreets(this);



            //CreateTheMeshes
            //Debug.Log("CreateAllMeshes StreetMesh");
            //Street.CreateAllMeshes(StreetMesh);

            //Debug.Log("CreateAllMeshes StreetMesh Bridge");
            //Bridge.CreateAllMeshes(StreetMesh);
            //Debug.Log("CreateAllMeshes StreetMesh Intersection");
            //Intersection.CreateAllMeshes(StreetMesh);

            //Debug.Log("CreateAllMeshes StreetMesh Street");
            //Street.CreateAllMeshes(StreetMesh); // A second time, cause Intersections change streetproperties
            msg.Start(Job.CreateBuildingMesh);
            SimpleClient.jobStatus[jobNumber] = msg;

            Building.CreateAllMeshes(BuildingMesh);
            msg.Stop(Job.CreateBuildingMesh);
            //Debug.Log("CreateAllMeshes Water");
            //Water.CreateAllMeshes(OtherMesh);
            //Debug.Log("CreateAllMeshes TrafficSignal");
            //TrafficSignal.CreateAllMeshes(OtherMesh);

            //StreetPolygon currentStreetPolygon;
            //bool hasLeftPolygon = false;
            //bool hasRightPolygon = false;
            //for (int i = 0; i < streets.Count; i++)
            //{
            //    for (int j = 0; j < streetPolygons.Count; j++)
            //    {
            //        hasLeftPolygon = streetPolygons[j].IsLefthandPolygonOf(streets[i]);
            //        hasRightPolygon = streetPolygons[j].IsRighthandPolygonOf(streets[i]);
            //    }
            //    if (!hasLeftPolygon)
            //    {
            //        if (StreetPolygon.GetLefthandStreetPolygon(streets[i], out currentStreetPolygon))
            //            streetPolygons.Add(currentStreetPolygon);
            //    }
            //    if (!hasRightPolygon)
            //    {
            //        if (StreetPolygon.GetRighthandStreetPolygon(streets[i], out currentStreetPolygon))
            //            streetPolygons.Add(currentStreetPolygon);
            //    }

            //    hasLeftPolygon = false;
            //    hasRightPolygon = false;
            //}

            //for (int i = 0; i < streetPolygons.Count; i++)
            //{
            //    streetPolygons[i].Triangulate(StreetMesh , MaterialManager.GetMaterial("error"));
            //}


            msg.Start(Job.FillMeshDivideMaterials);
            SimpleClient.jobStatus[jobNumber] = msg;
            TileMesh.FillMeshDivideMaterialsKeepMeshStructure(transform, true);
            msg.Stop(Job.FillMeshDivideMaterials);
            #endregion
        }
        #endregion

        msg.Start(Job.GarbageCollection);
        SimpleClient.jobStatus[jobNumber] = msg;
        System.GC.Collect();
        msg.Stop(Job.GarbageCollection);

        yield return(null);

        msg.Start(Job.ProceduralDone);
        SimpleClient.jobStatus[jobNumber] = msg;
        OnProceduralDoneLocal();
        msg.Stop(Job.Worker);
        msg.Stop();

        yield return(true);
    }
Esempio n. 17
0
    // Update is called once per frame
    void Update()
    {
        timePassed   += Time.deltaTime;
        changeTimeAI += Time.deltaTime;

        // Consider changing strategy
        if (changeTimeAI > timeBetweenChangeAI)
        {
            if (Random.Range(1, 4) == 1)
            {
                runner = true;
                chaser = false;
            }
            else
            {
                chaser = true;
                runner = false;
            }
            changeTimeAI = 0f;
        }

        GameObject player = GameObject.FindGameObjectWithTag("player");
        Vector3    moveTo = Vector3.zero;

        // Simulate AI
        if (chaser)
        {
            // Move player to coordinates
            moveTo.x = (player.transform.position.x) - this.transform.position.x;
            moveTo.y = (player.transform.position.y * 0.9f) - this.transform.position.y;
            moveTo.z = 0;

            this.transform.position += moveTo * Time.deltaTime;
        }
        else if (runner)
        {
            // Move player to coordinates
            moveTo.x = (player.transform.position.x * -1) - this.transform.position.x;
            moveTo.y = (player.transform.position.y * -1) - this.transform.position.y;
            moveTo.z = 0;

            this.transform.position += moveTo * Time.deltaTime;
        }

        // If so, do attack
        if (timePassed > timeBetweenShoot)
        {
            // Get info about player location
            double distance = System.Math.Sqrt(System.Math.Pow(player.transform.position.x + this.transform.position.x, 2) + System.Math.Pow(player.transform.position.y + this.transform.position.y, 2));

            // Shoot fire if within range in the x direction
            if (distance > 0.5f)
            {
                if (this.transform.position.y + 0.2 > player.transform.position.y &&
                    this.transform.position.y - 0.2 < player.transform.position.y)
                {
                    Vector3 shootAt = this.transform.position;
                    if (this.transform.position.x < player.transform.position.x)
                    {
                        shootAt.x = 1;
                    }
                    else
                    {
                        shootAt.x = -1;
                    }
                    shootAt.y = 0;
                    shootAt.z = 0;

                    Fire(shootAt);
                    timePassed = 0f;
                }
                if (this.transform.position.x + 0.2 > player.transform.position.x &&
                    this.transform.position.x - 0.2 < player.transform.position.x)
                {
                    Vector3 shootAt = this.transform.position;
                    shootAt.x = 0;
                    if (this.transform.position.y < player.transform.position.y)
                    {
                        shootAt.y = 1;
                    }
                    else
                    {
                        shootAt.y = -1;
                    }
                    shootAt.z = 0;

                    Fire(shootAt);
                    timePassed = 0f;
                }
            }
            // Shoot grass when player gets too close
            else if (distance < 1f)
            {
                Grass(player.transform.position);
                timePassed = 0f;
            }
            // Randomly drop water
            if (Random.Range(1, 100) == 7)
            {
                Water(moveTo);
                timePassed = 0f;
            }
        }

        // Check if dead
        if (HP <= 0)
        {
            Destroy(this.gameObject);

            Fire fScript = FirePrefab.GetComponent <Fire>();
            fScript.Reload();

            Water wScript = WaterPrefab.GetComponent <Water>();
            wScript.Reload();

            Grass gScript = GrassPrefab.GetComponent <Grass>();
            gScript.Reload();

            GameObject pw = GameObject.FindGameObjectWithTag("playerwin");
            pw.guiText.enabled = true;
            GameObject sb = GameObject.FindGameObjectWithTag("spacebar");
            sb.guiText.enabled = true;

            Main m = Camera.main.camera.GetComponent <Main>();
            m.gameIsOver();

            GameObject p = GameObject.FindGameObjectWithTag("player");
            p.GetComponent <Player>().HP = 100000;
        }
    }
Esempio n. 18
0
        public void WaterImplementsINotifyPropertyChanged()
        {
            var water = new Water();

            Assert.IsAssignableFrom <INotifyPropertyChanged>(water);
        }
Esempio n. 19
0
	void Awake() {
		Instance = this;
	}
Esempio n. 20
0
	void OnDestroy() {
		if (Instance == this) {
			Instance = null;
		}
	}
        protected void LoadOldBoundary(XmlNode node, WorldObjectCollection collection)
        {
            string name = null;
            XmlNode pointsNode = null;
            XmlNode semanticsNode = null;
            // int priority;

            // get the name
            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                    case "Name":
                        name = childNode.InnerText;
                        break;
                    case "Points":
                        pointsNode = childNode;
                        break;
                    case "Attributes":
                        semanticsNode = childNode;
                        break;
                    default:
                        break;
                }
            }

            // if the boundary has no points, just call it bogus and return
            if (pointsNode == null)
            {
                return;
            }

            // create and add the boundary to the world
            Boundary boundary = new Boundary(collection, this, name, 100);
            collection.Add(boundary);

            // set up the points
            foreach (XmlNode pointNode in pointsNode.ChildNodes)
            {
                if (pointNode.Name == "Point")
                {
                    XmlNode locNode = pointNode.SelectSingleNode("Position");
                    Vector3 pointPos = GetVectorAttributes(locNode);

                    int pointNum;
                    boundary.Points.AddPoint(pointPos, out pointNum);
                }
            }

            if (semanticsNode != null)
            {
                // handle boundary semantics
                foreach (XmlNode semanticNode in semanticsNode.ChildNodes)
                {
                    switch (semanticNode.Name)
                    {
                        case "WaterAttribute":
                            XmlNode heightNode = semanticNode.SelectSingleNode("Height");
                            float height = float.Parse(heightNode.InnerText);
                            Water water = new Water(height, boundary, this);
                            boundary.Add(water);
                            break;
                        case "ForestAttribute":
                            XmlNode seedNode = semanticNode.SelectSingleNode("Seed");
                            int seed = int.Parse(seedNode.InnerText);

                            XmlNode speedWindNode = semanticNode.SelectSingleNode("SpeedWindFile");
                            string speedWindFile = speedWindNode.InnerText;

                            XmlNode windSpeedNode = semanticNode.SelectSingleNode("WindSpeed");
                            float windSpeed = float.Parse(windSpeedNode.InnerText);

                            XmlNode windDirNode = semanticNode.SelectSingleNode("WindDirection");
                            Vector3 windDir = GetVectorAttributes(windDirNode);

                            // Add the forest object
                            Forest forest = new Forest(speedWindFile, windSpeed, windDir, seed, boundary, this);
                            boundary.Add(forest);

                            XmlNode treeTypesNode = semanticNode.SelectSingleNode("TreeTypes");
                            if (treeTypesNode != null)
                            {
                                foreach (XmlNode treeTypeNode in treeTypesNode.ChildNodes)
                                {
                                    XmlNode treeNameNode = treeTypeNode.SelectSingleNode("TreeName");
                                    string treeName = treeNameNode.InnerText;

                                    XmlNode treeFilenameNode = treeTypeNode.SelectSingleNode("TreeDescriptionFilename");
                                    string treeFilename = treeFilenameNode.InnerText;

                                    XmlNode scaleNode = treeTypeNode.SelectSingleNode("Scale");
                                    float scale = float.Parse(scaleNode.InnerText);

                                    XmlNode scaleVarianceNode = treeTypeNode.SelectSingleNode("ScaleVariance");
                                    float scaleVariance = float.Parse(scaleVarianceNode.InnerText);

                                    XmlNode instancesNode = treeTypeNode.SelectSingleNode("Instances");
                                    uint instances = uint.Parse(instancesNode.InnerText);

                                    Tree tree = new Tree(treeName, treeFilename, scale, scaleVariance, instances, forest, this);
                                    forest.Add(tree);
                                }
                            }

                            break;
                        case "Fog":
                            XmlNode redNode = semanticNode.SelectSingleNode("ColorRed");
                            int red = int.Parse(redNode.InnerText);

                            XmlNode greenNode = semanticNode.SelectSingleNode("ColorGreen");
                            int green = int.Parse(greenNode.InnerText);

                            XmlNode blueNode = semanticNode.SelectSingleNode("ColorBlue");
                            int blue = int.Parse(blueNode.InnerText);

                            XmlNode nearNode = semanticNode.SelectSingleNode("Near");
                            float near = float.Parse(nearNode.InnerText);

                            XmlNode farNode = semanticNode.SelectSingleNode("Far");
                            float far = int.Parse(farNode.InnerText);

                            ColorEx fogColor = new ColorEx(((float)red) / 255f, ((float)green) / 255f, ((float)blue) / 255f);
                            Fog fog = new Fog(this, boundary, fogColor, near, far);
                            boundary.Add(fog);

                            break;
                        case "Sound":
                            break;
                        default:
                            break;
                    }
                }
            }
        }
Esempio n. 22
0
        public void ShouldNotHaveLemonByDefault()
        {
            var water = new Water();

            Assert.False(water.Lemon);
        }
        // Adjust plant health if watered, lighted and fed.
        private void AdjustHealth(Water water, Light light, Food food)
        {
            if (Stage == Stage.Dead)
            {
                Health = GameSettings.Default.DeathThreshold;
            }
            else
            {
                if (water == Water && Health <= MaxHealth)
                    Health++;
                else
                    Health--;

                if (light == Light && Health <= MaxHealth)
                    Health++;
                else
                    Health--;

                if (food == Food && food != Food.None && Health <= MaxHealth)
                    Health++;
            }
        }
Esempio n. 24
0
        public void ShouldBeSmallByDefault()
        {
            var water = new Water();

            Assert.Equal(Size.Small, water.Size);
        }
        // What to do when plant grows.
        public IChronic Grow(Water water, Light light, Food food)
        {
            if (Stage == Stage.Vegetative || Stage == Stage.Seed || Stage == Stage.Clone || Stage == Stage.Flowering)
            {
                Age++;
                AdjustHealth(water, light, food);
                AdjustQuality(water, light, food);

                if (Stage != Stage.Seed)
                {
                    AdjustHeight(water, light, food, Stage);
                }

                if (Stage == Stage.Flowering)
                {
                    AdjustYield(water, light, food);
                    AdjustTHC(FloweringAge, 5);
                    AdjustCBD(FloweringAge, 5);
                }

                var isAdvanced = AdvanceStage(light);
            }

            return this;
        }
Esempio n. 26
0
        private void PrepareToRender()
        {
            // reset shadowed water rect
            shadowedWaterRect = new Rect(1.0f, 1.0f, -1.0f, -1.0f);

#if UNITY_EDITOR
            if (IsSceneViewCamera(thisCamera))
            {
                return;                                         // don't do any of the following stuff for editor cameras
            }
#endif

            // find containing water
            float waterEnterTolerance = thisCamera.nearClipPlane * Mathf.Tan(thisCamera.fieldOfView * 0.5f * Mathf.Deg2Rad) * 3.0f;
            var   newWater            = Water.FindWater(transform.position, waterEnterTolerance, out isInsideSubtractiveVolume, out isInsideAdditiveVolume);

            if (newWater != containingWater)
            {
                if (containingWater != null && submersionState != SubmersionState.None)
                {
                    submersionState = SubmersionState.None;
                    SubmersionStateChanged.Invoke(this);
                }

                containingWater = newWater;
                submersionState = SubmersionState.None;

                if (waterSample != null)
                {
                    waterSample.Stop();
                    waterSample = null;
                }

                if (newWater != null && newWater.Volume.Boundless)
                {
                    waterSample = new WaterSample(containingWater, WaterSample.DisplacementMode.Height, 0.4f);
                    waterSample.Start(transform.position);
                }
            }

            // determine submersion state
            SubmersionState newSubmersionState;

            if (waterSample != null)
            {
                waterLevel = waterSample.GetAndReset(transform.position, WaterSample.ComputationsMode.Normal).y;

                if (transform.position.y - waterEnterTolerance < waterLevel)
                {
                    if (transform.position.y + waterEnterTolerance < waterLevel)
                    {
                        newSubmersionState = SubmersionState.Full;
                    }
                    else
                    {
                        newSubmersionState = SubmersionState.Partial;
                    }
                }
                else
                {
                    newSubmersionState = SubmersionState.None;
                }
            }
            else
            {
                newSubmersionState = containingWater != null ? SubmersionState.Partial : SubmersionState.None;                                  // for non-boundless water always use Partial state as determining this would be too costly
            }

            if (newSubmersionState != submersionState)
            {
                submersionState = newSubmersionState;
                SubmersionStateChanged.Invoke(this);
            }
        }
Esempio n. 27
0
        public Board(string filename)
        {
            TextReader tr = new StreamReader(filename);
            rows = int.Parse(tr.ReadLine());
            cols = int.Parse(tr.ReadLine());
            board = new Square[rows, cols];
            string line;
            int row = 0;
            while ((line = tr.ReadLine()) != null)
            {
                int col= 0;
                foreach (char ch in line.Trim())
                {
                    Coordinate coordinate = new Coordinate(row, col);
                    MapElement element;
                    switch (ch)
                    {

                        case 'X':
                            element = new Wall(coordinate);
                            break;
                        case '~':
                            element = new Water(coordinate);
                            break;
                        case '.':
                            element = new Floor(coordinate);
                            break;
                        default:
                            element = new Floor(coordinate);
                            break;
                    }
                    Square square = new Square(coordinate, element);
                    board[row, col] = square;
                    col++;
                }
                row++;
                cols = col;
            }
            rows = row;
            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    if (r > 0)
                    {
                        Square neighbor = board[r - 1, c];
                        board[r, c].AddNeighbor(neighbor);
                    }
                    if (r < rows - 1)
                    {
                        Square neighbor = board[r + 1, c];
                        board[r, c].AddNeighbor(neighbor);
                    }
                    if (c > 0)
                    {
                        Square neighbor = board[r, c - 1];
                        board[r, c].AddNeighbor(neighbor);
                    }
                    if (c < cols - 1)
                    {
                        Square neighbor = board[r, c+ 1];
                        board[r, c].AddNeighbor(neighbor);
                    }
                }
            }

            tr.Close();
        }
 public virtual void Visit(Water water)
 {
 }
Esempio n. 29
0
 public override void Start()
 {
     base.Start();
     inwater = Water.nullWater;
 }
Esempio n. 30
0
        /// <summary>
        /// This method adds entrees to the list by converting the
        /// sender object to a button and filtering on the name of the button
        /// that was pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddItemToList(object sender, RoutedEventArgs e)
        {
            //Ensure the DataContext is an Order and not NULL
            if (DataContext is Order data)
            {
                if (sender is Button)
                {
                    IOrderItem       item;
                    FrameworkElement screen = null;
                    var orderControl        = this.FindAncestor <OrderControl>();

                    //Cast sender to button
                    Button b = (Button)sender;

                    //Filter which button was pressed based on name
                    switch (b.Name)
                    {
                    case "AddAngryChickenButton":
                        item   = new AngryChicken();
                        screen = new AngryChickenCustomization(DataContext);
                        break;

                    case "AddCowpokeChiliButton":
                        item   = new CowpokeChili();
                        screen = new CowpokeChiliCustomization(DataContext);
                        break;

                    case "AddDakotaDoubleBurgerButton":
                        item   = new DakotaDoubleBurger();
                        screen = new DakotaDoubleCustomization(DataContext);
                        break;

                    case "AddPecosPulledPorkButton":
                        item   = new PecosPulledPork();
                        screen = new PecosPulledPorkCustomization(DataContext);
                        break;

                    case "AddRustlersRibsButton":
                        item = new RustlersRibs();
                        break;

                    case "AddTexasTripleBurgerButton":
                        item   = new TexasTripleBurger();
                        screen = new TexasTripleCustomization(DataContext);
                        break;

                    case "AddTrailBurgerButton":
                        item   = new TrailBurger();
                        screen = new TrailBurgerCustomization(DataContext);
                        break;

                    case "AddBakedBeansButton":
                        item = new BakedBeans();
                        break;

                    case "AddChiliCheeseFriesButton":
                        item = new ChiliCheeseFries();
                        break;

                    case "AddCornDodgersButton":
                        item = new CornDodgers();
                        break;

                    case "AddPandeCampoButton":
                        item = new PanDeCampo();
                        break;

                    case "AddCowboyCoffeeButton":
                        item   = new CowboyCoffee();
                        screen = new CowboyCoffeeCustomization(DataContext);
                        break;

                    case "AddJerkedSodaButton":
                        item   = new JerkedSoda();
                        screen = new JerkedSodaCustomization(DataContext);
                        break;

                    case "AddTexasTeaButton":
                        item   = new TexasTea();
                        screen = new TexasTeaCustomization(DataContext);
                        break;

                    case "AddWaterButton":
                        item   = new Water();
                        screen = new WaterCustomization(DataContext);
                        break;

                    default:
                        throw new NotImplementedException("Unknown button clicked");
                    }
                    if (screen != null)
                    {
                        screen.DataContext = item;
                    }
                    data.Add(item);
                    orderControl?.SwapScreen(screen);
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// ギミック設置
        /// by柏 SE実装 2016.12.14
        /// </summary>
        /// <param name="mapdata">マップデータの二元配列</param>
        /// <param name="MapThings">マップ上の物のList</param>
        public static void CreateGimmicks(int[,] mapdata, List <GameObject> MapThings, Sound sound)
        {
            for (int i = 0; i < mapdata.GetLength(0); i++)
            {
                for (int j = 0; j < mapdata.GetLength(1); j++)
                {
                    switch (mapdata[i, j])
                    {
                    case (int)GimmickType.ICE:
                    {
                        Ice ice = new Ice(new Vector2(j * 64, i * 64), Vector2.Zero);
                        MapThings.Add(ice);
                        break;
                    }

                    case (int)GimmickType.IRON:
                    {
                        Iron iron = new Iron(new Vector2(j * 64, i * 64), Vector2.Zero);
                        MapThings.Add(iron);
                        break;
                    }

                    case (int)GimmickType.LIGHT:
                    {
                        Light light = new Light(new Vector2(j * 64, i * 64));
                        MapThings.Add(light);
                        break;
                    }

                    case (int)GimmickType.STRAW:
                    {
                        Straw straw = new Straw(new Vector2(j * 64, i * 64));
                        MapThings.Add(straw);
                        break;
                    }

                    case (int)GimmickType.COAL:
                    {
                        Coal coal = new Coal(new Vector2(j * 64, i * 64), Vector2.Zero);
                        MapThings.Add(coal);
                        break;
                    }

                    case (int)GimmickType.GOAL:
                    {
                        Goal goal = new Goal(new Vector2(j * 64, i * 64), sound);
                        MapThings.Add(goal);
                        break;
                    }

                    case (int)GimmickType.WATER:
                    {
                        Water water = new Water(new Vector2(j * 64, i * 64), Vector2.Zero);
                        MapThings.Add(water);
                        break;
                    }

                    case (int)GimmickType.WOOD:
                    {
                        Wood wood = new Wood(new Vector2(j * 64, i * 64));
                        MapThings.Add(wood);
                        break;
                    }

                    case (int)GimmickType.TREE:
                    {
                        Tree tree = new Tree(new Vector2(j * 64, i * 64));
                        MapThings.Add(tree);
                        break;
                    }

                    case (int)GimmickType.SAND:
                    {
                        Sand sand = new Sand(new Vector2(j * 64, i * 64), Vector2.Zero);
                        MapThings.Add(sand);
                        break;
                    }

                    case (int)GimmickType.BALLOON:
                    {
                        Balloon balloon = new Balloon(new Vector2(j * 64, i * 64), Vector2.Zero);
                        MapThings.Add(balloon);
                        break;
                    }

                    //葉梨竜太
                    case (int)GimmickType.HIGHLIGHT3:
                    {
                        MoveLight moveLight = new MoveLight(new Vector2(j * 64, i * 64), new Vector2(j * 64, (i + 3) * 64), Parameter.MoveLightSpeed);
                        MapThings.Add(moveLight);
                        break;
                    }

                    case (int)GimmickType.SIDELIGHT3:
                    {
                        MoveLight moveLight = new MoveLight(new Vector2(j * 64, i * 64), new Vector2((j + 3) * 64, i * 64), Parameter.MoveLightSpeed);
                        MapThings.Add(moveLight);
                        break;
                    }

                    case (int)GimmickType.HIGHLIGHT5:
                    {
                        MoveLight moveLight = new MoveLight(new Vector2(j * 64, i * 64), new Vector2(j * 64, (i + 5) * 64), Parameter.MoveLightSpeed);
                        MapThings.Add(moveLight);
                        break;
                    }

                    case (int)GimmickType.SIDELIGHT5:
                    {
                        MoveLight moveLight = new MoveLight(new Vector2(j * 64, i * 64), new Vector2((j + 5) * 64, i * 64), Parameter.MoveLightSpeed);
                        MapThings.Add(moveLight);
                        break;
                    }

                    case (int)GimmickType.JSIGN:
                    {
                        Sign sign = new Sign(new Vector2(j * 64, i * 64), (int)GimmickType.JSIGN);
                        MapThings.Add(sign);
                        break;
                    }

                    //葉梨竜太 11/30
                    case (int)GimmickType.BOMB:
                    {
                        Bomb bomb = new Bomb(new Vector2(j * 64, i * 64), sound, Vector2.Zero);
                        MapThings.Add(bomb);
                        break;
                    }

                    //葉梨竜太
                    case (int)GimmickType.IGNITER_UR:
                    {
                        Igniter igniter = new Igniter(new Vector2(j * 64, i * 64), (int)GimmickType.IGNITER_UR);
                        MapThings.Add(igniter);
                        break;
                    }

                    case (int)GimmickType.IGNITER_UL:
                    {
                        Igniter igniter = new Igniter(new Vector2(j * 64, i * 64), (int)GimmickType.IGNITER_UL);
                        MapThings.Add(igniter);
                        break;
                    }

                    case (int)GimmickType.IGNITER_DR:
                    {
                        Igniter igniter = new Igniter(new Vector2(j * 64, i * 64), (int)GimmickType.IGNITER_DR);
                        MapThings.Add(igniter);
                        break;
                    }

                    case (int)GimmickType.IGNITER_DL:
                    {
                        Igniter igniter = new Igniter(new Vector2(j * 64, i * 64), (int)GimmickType.IGNITER_DL);
                        MapThings.Add(igniter);
                        break;
                    }

                    case (int)GimmickType.IGNITER_HIGHT:
                    {
                        Igniter igniter = new Igniter(new Vector2(j * 64, i * 64), (int)GimmickType.IGNITER_HIGHT);
                        MapThings.Add(igniter);
                        break;
                    }

                    case (int)GimmickType.IGNITER_SIDE:
                    {
                        Igniter igniter = new Igniter(new Vector2(j * 64, i * 64), (int)GimmickType.IGNITER_SIDE);
                        MapThings.Add(igniter);
                        break;
                    }

                    //葉梨竜太
                    case (int)GimmickType.MSIGN:
                    {
                        Sign sign = new Sign(new Vector2(j * 64, i * 64), (int)GimmickType.MSIGN);
                        MapThings.Add(sign);
                        break;
                    }

                    case (int)GimmickType.RSIGN:
                    {
                        Sign sign = new Sign(new Vector2(j * 64, i * 64), (int)GimmickType.RSIGN);
                        MapThings.Add(sign);
                        break;
                    }

                    case (int)GimmickType.LSIGN:
                    {
                        Sign sign = new Sign(new Vector2(j * 64, i * 64), (int)GimmickType.LSIGN);
                        MapThings.Add(sign);
                        break;
                    }

                    case (int)GimmickType.CSIGN:
                    {
                        Sign sign = new Sign(new Vector2(j * 64, i * 64), (int)GimmickType.CSIGN);
                        MapThings.Add(sign);
                        break;
                    }

                    // 1/13 葉梨竜太
                    case (int)GimmickType.ROCK:
                    {
                        Stone stone = new Stone(new Vector2(j * 64, i * 64));
                        MapThings.Add(stone);
                        break;
                    }
                    }
                }
            }
        }
Esempio n. 32
0
        private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background)
        {
            CassetteBlock.Blocks.Clear();

            using (Graphics g = Graphics.FromImage(map)) {
                List <Entity> ents = new List <Entity>();
                for (int i = entities.Children.Count - 1; i >= 0; i--)
                {
                    MapElement child = entities.Children[i];

                    Entity entity = null;
                    if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? Spikes.FromElement(child) : null;
                    }
                    else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? TriggerSpikes.FromElement(child) : null;
                    }
                    else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterCabinet.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? IntroCar.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClothesLine.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ColorSwitch.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bonfire.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TrapDoor.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? MovingPlatform.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SinkingPlatform.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterDoor.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bridge.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? BridgeFixed.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? JumpThru.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Door.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? BlockField.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Lamp.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Haha.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? WaterFall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Water.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Key.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ResortLantern.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bird.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Memorial.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? PlayerSpawn.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ZipMover.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Wire.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CrumbleBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Refill.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Spring.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FakeWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FakeWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? LightBeam.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Cobweb.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Cassette.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FlutterBird.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Checkpoint.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FallingBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FallingBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CassetteBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DashBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CoverupWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? NPC.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ForsakenCityGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SoundSource.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FriendlyGhost.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FloatingDebris.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HangingLamp.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? LockBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HeartGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HeartGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DreamMirror.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DarkChaser.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DreamBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TouchSwitch.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SwitchGate.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? InvisibleBarrier.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Payphone.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Spinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? RotateSpinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TrackSpinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TowerViewer.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = !background?ForegroundDebris.FromElement(child) : null;
                    }
                    else if (background)
                    {
                        Console.WriteLine(child.Name);
                    }
                    if (entity != null)
                    {
                        ents.Add(entity);
                    }
                }

                ents.Sort(delegate(Entity one, Entity two) {
                    int comp = two.Depth.CompareTo(one.Depth);
                    return(comp == 0 ? one.ID.CompareTo(two.ID) : comp);
                });

                for (int i = 0; i < ents.Count; i++)
                {
                    Entity entity = ents[i];
                    entity.Render(g, solids);
                }
            }
        }
Esempio n. 33
0
    private static void CalculateObliqueMatrix(ref Matrix4x4 projection, Vector4 clipPlane)
    {
        Vector4 vector  = projection.get_inverse() * new Vector4(Water.sgn(clipPlane.x), Water.sgn(clipPlane.y), 1f, 1f);
        Vector4 vector2 = clipPlane * (2f / Vector4.Dot(clipPlane, vector));

        projection.set_Item(2, vector2.x - projection.get_Item(3));
        projection.set_Item(6, vector2.y - projection.get_Item(7));
        projection.set_Item(10, vector2.z - projection.get_Item(11));
        projection.set_Item(14, vector2.w - projection.get_Item(15));
    }
        public void WaterShouldImplementINotifyPropertyChanged()
        {
            var item = new Water();

            Assert.IsAssignableFrom <INotifyPropertyChanged>(item);
        }
Esempio n. 35
0
        protected void FromXml(XmlReader r)
        {
            // first parse the attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "Name":
                        this.name = r.Value;
                        break;
                    case "Priority":
                        this.priority = int.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                        case "PointCollection":
                            if (!r.IsEmptyElement)
                            {
                                this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial,MPPointType.Boundary, r);
                                Add(points);
                                points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
                            }
                            break;
                        case "NameValuePairs":
                            this.nameValuePairs = new NameValueObject(r);
                            break;
                        case "Forest":
                            Forest forest = new Forest(r, this, app);
                            Add(forest);
                            break;
                        case "Fog":
                            Fog fog = new Fog(r, this, app);
                            Add(fog);
                            break;
                        case "Water":
                            Water water = new Water(r, this, app);
                            Add(water);
                            break;
                        case "Sound":
                            Sound sound = new Sound(r, (IWorldContainer)this, app);
                            Add(sound);
                            break;
                        case "Grass":
                            Grass grass = new Grass(r, this, app);
                            Add(grass);
                            break;
                        case "SpawnGen":
                            SpawnGen mob = new SpawnGen(r, app, this);
                            Add(mob);
                            break;
                        case "AmbientLight":
                            AmbientLight ambientLight = new AmbientLight(app, this, r);
                            Add(ambientLight);
                            break;
                        case "DirectionalLight":
                            DirectionalLight directionalLight = new DirectionalLight(app, this, r);
                            Add(directionalLight);
                            break;
                    }
                }
            }
            if (points == null)
            {
                this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, MPPointType.Boundary);
                Add(points);
                points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
            }
        }
Esempio n. 36
0
 public void Frost(Water water)
 {
     Console.WriteLine("Превращаем жидкость в лед");
     water.State = new SolidWaterState();
 }
Esempio n. 37
0
        /// <summary>
        /// Creates the map.
        /// </summary>
        /// <param name="randomizer">The randomizer.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Unknow tile type</exception>
        public Map CreateMap(ISquareRandomizer randomizer)
        {
            Map map = new Map(new Point(25, 25));

            CivilizationAlgorithms.PerlinNoise.GenerateHeightMap(100, 25, 25);

            for (int i = 0; i < 25; ++i)
            {
                for (int j = 0; j < 25; ++j)
                {
                    Square.Square newSquare;
                    switch (CivilizationAlgorithms.PerlinNoise.GetTileType(i, j))
                    {
                        case ManagedTileType.Desert:
                            newSquare = new Desert();
                            break;
                        case ManagedTileType.Water:
                            newSquare = new Water();
                            break;
                        case ManagedTileType.Mountain:
                            newSquare = new Mountain();
                            break;
                        case ManagedTileType.Field:
                            newSquare = new Field();
                            break;
                        default:
                            throw new System.Exception("Unknow tile type");
                            break;
                    }

                    switch (CivilizationAlgorithms.PerlinNoise.GetDecoratorType(i, j))
                    {
                        case ManagedDecoratorType.Fruit :
                            newSquare = new FruitSquareDecorator(newSquare);
                            break;
                        case ManagedDecoratorType.Iron :
                            newSquare = new IronSquareDecorator(newSquare);
                            break;
                        default:
                            //NADA
                            break;
                    }

                    map.ReplaceSquare(new Point(i, j), newSquare);
                    map.GetSquare(new Point(i, j)).Position = new Point(i, j);
                }
            }

            CivilizationAlgorithms.PerlinNoise.FindIdealPositions();

            map.IdealPosition1 = new Point
            {
                X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition1().X,
                Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition1().Y
            };

            map.IdealPosition2 = new Point
            {
                X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition2().X,
                Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition2().Y
            };

            map.IdealPosition3 = new Point
            {
                X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition3().X,
                Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition3().Y
            };

            return map;
        }
Esempio n. 38
0
 public void Heat(Water water)
 {
     Console.WriteLine("Превращаем жидкость в пар");
     water.State = new GasWaterState();
 }
Esempio n. 39
0
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="WaterNode" /> class.
        /// </summary>
        /// <param name="water">The water.</param>
        /// <param name="volume">
        /// The water volume. Can be <see langword="null"/>, see <see cref="Volume"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="water"/> is <see langword="null"/>.
        /// </exception>
        public WaterNode(Water water, Shape volume)
        {
            if (water == null)
            throw new ArgumentNullException("water");

              _water = water;
              Volume = volume;

              // Normally, Volume setter automatically calls Update() - but not when volume is null.
              if (Volume == null)
            Update(false);

              // The IsRenderable flag needs to be set to indicate that the scene node should
              // be handled during rendering.
              IsRenderable = true;

              EnableUnderwaterEffect = true;

              //MaxDepth = 100;
        }
Esempio n. 40
0
 public void UpdateMaterial(Water water, WaterQualityLevel qualityLevel)
 {
 }
Esempio n. 41
0
 public CaptainPlanet(Earth earth, Wind wind, Fire fire, Water water, Heart heart)
 {
 }
Esempio n. 42
0
 public void BuildShaderVariant(ShaderVariant variant, Water water, WaterQualityLevel qualityLevel)
 {
     variant.SetWaterKeyword("_PLANAR_REFLECTIONS", enabled && (!highQuality || !qualityLevel.allowHighQualityReflections));
     variant.SetWaterKeyword("_PLANAR_REFLECTIONS_HQ", enabled && highQuality && qualityLevel.allowHighQualityReflections);
 }
        // Adjust plant height if watered and lighted.
        private void AdjustHeight(Water water, Light light, Food food, Stage stage)
        {
            // Check if plant is alive and no longer a seed.
            if (stage == Stage.Vegetative || stage == Stage.Flowering || stage == Stage.Clone)
            {
                if (water == Water)
                    Height += 0.75;
                else
                    Height -= 0.75;

                if (light == Light)
                    Height += 0.75;
                else
                    Height -= 0.75;

                // No penalty for lack of food, just bonus growth.
                if (food == Food.Low || food == Food.Medium || food == Food.High)
                    Height++;
            }

            else if (stage == Stage.Dead)
                Height -= 0.75;

            else if (stage == Stage.Seed)
                Height = 0;

            if (Height < 0)
                Height = 0;
        }
Esempio n. 44
0
    // Token: 0x06001473 RID: 5235 RVA: 0x000259BC File Offset: 0x00023BBC
    public void OnWillRenderObject()
    {
        if (!base.enabled || !base.renderer || !base.renderer.sharedMaterial || !base.renderer.enabled)
        {
            return;
        }
        Camera current = Camera.current;

        if (!current)
        {
            return;
        }
        if (Water.s_InsideWater)
        {
            return;
        }
        Water.s_InsideWater         = true;
        this.m_HardwareWaterSupport = this.FindHardwareWaterSupport();
        Water.WaterMode waterMode = this.GetWaterMode();
        Camera          camera;
        Camera          camera2;

        this.CreateWaterObjects(current, out camera, out camera2);
        Vector3 position        = base.transform.position;
        Vector3 up              = base.transform.up;
        int     pixelLightCount = QualitySettings.pixelLightCount;

        if (this.m_DisablePixelLights)
        {
            QualitySettings.pixelLightCount = 0;
        }
        this.UpdateCameraModes(current, camera);
        this.UpdateCameraModes(current, camera2);
        if (waterMode >= Water.WaterMode.Reflective)
        {
            float     w     = -Vector3.Dot(up, position) - this.m_ClipPlaneOffset;
            Vector4   plane = new Vector4(up.x, up.y, up.z, w);
            Matrix4x4 zero  = Matrix4x4.zero;
            Water.CalculateReflectionMatrix(ref zero, plane);
            Vector3 position2 = current.transform.position;
            Vector3 position3 = zero.MultiplyPoint(position2);
            camera.worldToCameraMatrix = current.worldToCameraMatrix * zero;
            Vector4   clipPlane        = this.CameraSpacePlane(camera, position, up, 1f);
            Matrix4x4 projectionMatrix = current.projectionMatrix;
            Water.CalculateObliqueMatrix(ref projectionMatrix, clipPlane);
            camera.projectionMatrix = projectionMatrix;
            camera.cullingMask      = (-17 & this.m_ReflectLayers.value);
            camera.targetTexture    = this.m_ReflectionTexture;
            GL.SetRevertBackfacing(true);
            camera.transform.position = position3;
            Vector3 eulerAngles = current.transform.eulerAngles;
            camera.transform.eulerAngles = new Vector3(-eulerAngles.x, eulerAngles.y, eulerAngles.z);
            camera.Render();
            camera.transform.position = position2;
            GL.SetRevertBackfacing(false);
            base.renderer.sharedMaterial.SetTexture("_ReflectionTex", this.m_ReflectionTexture);
        }
        if (waterMode >= Water.WaterMode.Refractive)
        {
            camera2.worldToCameraMatrix = current.worldToCameraMatrix;
            Vector4   clipPlane2        = this.CameraSpacePlane(camera2, position, up, -1f);
            Matrix4x4 projectionMatrix2 = current.projectionMatrix;
            Water.CalculateObliqueMatrix(ref projectionMatrix2, clipPlane2);
            camera2.projectionMatrix   = projectionMatrix2;
            camera2.cullingMask        = (-17 & this.m_RefractLayers.value);
            camera2.targetTexture      = this.m_RefractionTexture;
            camera2.transform.position = current.transform.position;
            camera2.transform.rotation = current.transform.rotation;
            camera2.Render();
            base.renderer.sharedMaterial.SetTexture("_RefractionTex", this.m_RefractionTexture);
        }
        if (this.m_DisablePixelLights)
        {
            QualitySettings.pixelLightCount = pixelLightCount;
        }
        switch (waterMode)
        {
        case Water.WaterMode.Simple:
            Shader.EnableKeyword("WATER_SIMPLE");
            Shader.DisableKeyword("WATER_REFLECTIVE");
            Shader.DisableKeyword("WATER_REFRACTIVE");
            break;

        case Water.WaterMode.Reflective:
            Shader.DisableKeyword("WATER_SIMPLE");
            Shader.EnableKeyword("WATER_REFLECTIVE");
            Shader.DisableKeyword("WATER_REFRACTIVE");
            break;

        case Water.WaterMode.Refractive:
            Shader.DisableKeyword("WATER_SIMPLE");
            Shader.DisableKeyword("WATER_REFLECTIVE");
            Shader.EnableKeyword("WATER_REFRACTIVE");
            break;
        }
        Water.s_InsideWater = false;
    }
        // Adjust the actual yield of the plant.
        private void AdjustYield(Water water, Light light, Food food)
        {
            // If plant is flowering and has not reached flowering age, increase yield.
            if (Yield <= MaxYield && Age >= FloweringAge)
            {
                // Depending on the height, health and resources received adjust yield.
                if (water == Water)
                    Yield++;
                if (light == Light)
                    Yield++;
                if (food == Food)
                    Yield += 2;
                if (Height >= 0 || Height <= 50)
                    Yield += 0.25;
                else if (Height >= 51 || Height <= 100)
                    Yield += 0.5;
                else if (Height >= 101 || Height <= 150)
                    Yield += 0.75;
                else if (Height >= 151 || Height <= 200)
                    Yield += 1;
                if (Health < 0)
                    Yield -= 2;
                else if (Health >= 0 && Health <= 50)
                    Yield += 0.25;
                else if (Health > 50 && Health <= 100)
                    Yield += 0.25;
            }

            // If flowering age has gone by, decrease yield.
            else if (Age > FloweringAge)
            {
                Yield *= 0.95;
            }

            else return;
        }
Esempio n. 46
0
        public void ShouldHaveCorrectDefaultPrice()
        {
            Water water = new Water();

            Assert.Equal <double>(.10, water.Price);
        }
 // Use this for initialization
 void Start()
 {
     objectWater = GetComponent<Water>();
     setQuality();
 }
Esempio n. 48
0
        public void ShouldHaveEmptySpecialListByDefault()
        {
            Water wawa = new Water();

            Assert.Empty(wawa.Special);
        }
Esempio n. 49
0
        public static MyTuple <float, float, float, int> GetWaveData(long ID)
        {
            Water Water = WaterMod.Static.Waters[ID];

            return(new MyTuple <float, float, float, int>(Water.waveHeight, Water.waveSpeed, Water.waveScale, Water.seed));
        }
Esempio n. 50
0
        public void ShouldHaveCorrectDefaultCalories()
        {
            Water water = new Water();

            Assert.Equal <uint>(0, water.Calories);
        }
Esempio n. 51
0
		public void Tick()
		{
			// If failed to place something N consecutive times, wait M ticks until resuming building production
			if (failCount >= ai.Info.MaximumFailedPlacementAttempts && --failRetryTicks <= 0)
			{
				var currentBuildings = world.ActorsWithTrait<Building>()
					.Where(a => a.Actor.Owner == player)
					.Count();

				var baseProviders = world.ActorsWithTrait<BaseProvider>()
					.Where(a => a.Actor.Owner == player)
					.Count();

				// Only bother resetting failCount if either a) the number of buildings has decreased since last failure M ticks ago,
				// or b) number of BaseProviders (construction yard or similar) has increased since then.
				// Otherwise reset failRetryTicks instead to wait again.
				if (currentBuildings < cachedBuildings || baseProviders > cachedBases)
					failCount = 0;
				else
					failRetryTicks = ai.Info.StructureProductionResumeDelay;
			}

			if (waterState == Water.NotChecked)
			{
				if (ai.EnoughWaterToBuildNaval())
					waterState = Water.EnoughWater;
				else
				{
					waterState = Water.NotEnoughWater;
					checkForBasesTicks = ai.Info.CheckForNewBasesDelay;
				}
			}

			if (waterState == Water.NotEnoughWater && --checkForBasesTicks <= 0)
			{
				var currentBases = world.ActorsWithTrait<BaseProvider>()
					.Where(a => a.Actor.Owner == player)
					.Count();

				if (currentBases > cachedBases)
				{
					cachedBases = currentBases;
					waterState = Water.NotChecked;
				}
			}

			// Only update once per second or so
			if (--waitTicks > 0)
				return;

			playerBuildings = world.ActorsWithTrait<Building>()
				.Where(a => a.Actor.Owner == player)
				.Select(a => a.Actor)
				.ToArray();

			var active = false;
			foreach (var queue in ai.FindQueues(category))
				if (TickQueue(queue))
					active = true;

			// Add a random factor so not every AI produces at the same tick early in the game.
			// Minimum should not be negative as delays in HackyAI could be zero.
			var randomFactor = ai.Random.Next(0, ai.Info.StructureProductionRandomBonusDelay);

			// Needs to be at least 4 * OrderLatency because otherwise the AI frequently duplicates build orders (i.e. makes the same build decision twice)
			waitTicks = active ? 4 * world.LobbyInfo.GlobalSettings.OrderLatency + ai.Info.StructureProductionActiveDelay + randomFactor
				: ai.Info.StructureProductionInactiveDelay + randomFactor;
		}
Esempio n. 52
0
    private void Awake()
    {
        // Setting up references.
        rigidBody = GetComponent<Rigidbody>();
        collider = GetComponent<SphereCollider>();
        stickyAura.transform.localScale = Vector3.zero;

        // adjust vars
        groundDist = gameObject.GetComponent<Collider>().bounds.extents.y;
        int arrSize = Math.Min(GameObject.FindObjectsOfType<Collider>().Length, 100);
        collidingWith = new Collision[arrSize];
        groundedTo = new Collision[arrSize];
        if (adjustForSize) {
            maxSpeed *= transform.localScale.x;
            acceleration *= transform.localScale.x;
        }
        localRadius = collider.radius*Mathf.Max(Mathf.Max(transform.localScale.x, transform.localScale.y), transform.localScale.z);
        inwater = Water.nullWater;
    }
Esempio n. 53
0
	/**
	 * Called when the script is loaded, before the game starts
	 */
	void Awake () {
		S = this;
	}
Esempio n. 54
0
    //deparent from gears
    void OnTriggerExit(Collider coll)
    {
        if (coll.gameObject.tag == "gear"&&transform.parent==coll.transform)
        {
            Vector3 diff = Vector3.zero;//transform.position-coll.transform.position;
            Vector3 gearSpeed = coll.GetComponent<EnviroGear>().GetVelAtPoint(transform.position);
            Vector3 speed = Vector3.Cross((transform.position-transform.parent.position), Vector3.back).normalized*rotVel*radius*50*Mathf.PI/180;
            rigidBody.velocity += diff + gearSpeed - speed;

            transform.parent.GetComponent<EnviroGear>().momentOfIntertia -= mass*radius*radius;
            transform.SetParent(null);
        }

        if (inwater!=Water.nullWater && inwater==coll.gameObject.GetComponent<Water>())
            inwater = Water.nullWater;
    }
Esempio n. 55
0
        public void ShouldHaveCorrectDefaultIce()
        {
            Water water = new Water();

            Assert.True(water.Ice);
        }
Esempio n. 56
0
 public void Awake()
 {
     //Change behavior to water element
     element = new Water();
 }
Esempio n. 57
0
    void OnTriggerEnter(Collider coll)
    {
        if (engaged && coll.gameObject.tag == "gear") {
            // handle parent
            if (transform.parent==coll.transform)
                return;

            rigidBody.velocity = Vector3.zero;
            rigidBody.angularVelocity = Vector3.zero;
            transform.parent = coll.gameObject.transform;
            radius = transform.localPosition.magnitude;
            //alter angular momentum...
            //transform.parent.GetComponent<EnviroGear>().angularMomentum -= 20;
            transform.parent.GetComponent<EnviroGear>().momentOfIntertia += mass*radius*radius;
        }

        Water tempWater = coll.gameObject.GetComponent<Water>();
        if (tempWater!=null)
            inwater = tempWater;
    }
Esempio n. 58
0
        public void ShouldHaveCorrectDefaultSize()
        {
            Water water = new Water();

            Assert.Equal <Size>(Size.Small, water.Size);
        }
Esempio n. 59
0
 void OnTriggerStay(Collider coll)
 {
     Water tempWater = coll.gameObject.GetComponent<Water>();
     if (inwater==Water.nullWater && tempWater!=null)
         inwater = tempWater;
 }
Esempio n. 60
0
        public void ShouldHaveCorrectDefaultLemon()
        {
            Water water = new Water();

            Assert.False(water.Lemon);
        }