private IEnumerator StartFoodSearch() { if (_isSearchingForFood || Edibles.Count == 0) { yield break; } _isSearchingForFood = true; Grass grass = null; while (grass is null) { yield return(new WaitForSeconds(UnityEngine.Random.Range(0f, 2f))); grass = SearchEngine.FindClosestGrass(_character.MotionComponent.GridPosition); } _eatFoodTask = new EatFoodTask(_character, SearchEngine.FindNodeNear(Utils.NodeAt(grass.Position), _character.MotionComponent.Node), grass); _eatFoodTask.ResultHandler += HandleGetFoodResult; _character.AI.CommandProcessor.AddTask(_eatFoodTask); while (_eatFoodTask != null) { yield return(null); } _isSearchingForFood = false; }
//这个生成算法的问题在于生成的控制点y值永远增大,实际上有可能弯曲 //试试看抖动取样? public static void CreatN(uint n, float Height, float Width, float Twist) { Vector3 up = new Vector3(0, 1, 0); Vector3 right = new Vector3(0, 0, 1); Vector3 Ee, Ew, En; Vector3 pre, next; for (int i = 0; i < n; i++) { Grass g = new Grass(); float sintheta = Random.Range(-1.0f, 1.0f); float costheta = Mathf.Sqrt(1 - sintheta * sintheta); Vector3 ButtomEw = Width * new Vector3( Vector3.Dot(new Vector3(costheta, 0, sintheta), right), Vector3.Dot(new Vector3(0, 1, 0), right), Vector3.Dot(new Vector3(-sintheta, 0, costheta), right)); pre = new Vector3(Random.Range(-50.0f, 50.0f), 0, Random.Range(-50.0f, 50.0f)); for (int j = 0; j < CtrlPointNum; j++) { next = pre + up * (j + 1) * Height; next.x += Random.Range(-1.0f, 1.0f) * Twist; next.z += Random.Range(-1.0f, 1.0f) * Twist; //简单插值,具体计算在shader中 Ew = ButtomEw * (CtrlPointNum - (float)j) / CtrlPointNum; g.ControlPoints[j] = new GrassControlPoint(pre, Ew); pre = next; } Grasses.Add(g); } }
public bool GrassTrampled(Grass grass) { float minX = grass.transform.position.x - 0.2f; float maxX = grass.transform.position.x + 0.2f; float minY = grass.transform.position.y - 0.2f; float maxY = grass.transform.position.y + 0.2f; for (int i = 0; i < sheepies.Count; i++) { if (sheepies[i] != null) { if (minX < sheepies[i].transform.position.x && maxX > sheepies[i].transform.position.x) { if (minY < sheepies[i].transform.position.y && maxY > sheepies[i].transform.position.y) { return(true); } } } } for (int y = 0; y < wolves.Count; y++) { if (wolves[y] != null) { if (minX < wolves[y].transform.position.x && maxX > wolves[y].transform.position.x) { if (minY < wolves[y].transform.position.y && maxY > wolves[y].transform.position.y) { return(true); } } } } return(false); }
private static bool Grass_seasonUpdate_Prefix(Grass __instance, ref bool __result) { try { // Only applicable to standard grass in winter locations. if (__instance.grassType.Value != 1 || Game1.GetSeasonForLocation(__instance.currentLocation) != "winter") { return(true); } // Only applicable in configured locations and areas. if (!Data.WinterGrasses.Exists((grassArea) => grassArea.checkArea(__instance.currentLocation, __instance.currentTileLocation))) { return(true); } // Update the grass as if it weren't winter. __instance.loadSprite(); __result = false; return(false); } catch (Exception e) { Monitor.Log($"Failed in {nameof (Grass_seasonUpdate_Prefix)}:\n{e}", LogLevel.Error); Monitor.Log(e.StackTrace, LogLevel.Trace); } return(true); }
/// <summary>This is code that will replace some game code, this is ran whenever the season gets updated. Used for ensuring grass can't live in the config specified seasons.</summary> /// <param name="__instance">The current grass instance that is being patched.</param> /// <param name="__result">Whether all grass should be killed.</param> /// <returns>False meaning the original method will never get ran.</returns> internal static bool SeasonUpdatePrefix(Grass __instance, ref bool __result) { switch (Game1.currentSeason) { case "spring": { __result = !ModEntry.Config.CanGrassLiveInSpring; break; } case "summer": { __result = !ModEntry.Config.CanGrassLiveInSummer; break; } case "fall": { __result = !ModEntry.Config.CanGrassLiveInFall; break; } case "winter": { __result = !ModEntry.Config.CanGrassLiveInWinter; break; } } // recalculate the new textures for grass __instance.loadSprite(); // return false so the base method doesn't get ran return(false); }
// Start is called before the first frame update void Start() { //collider = GetComponent<BoxCollider2D>(); spriteObject = gameObject.GetChild("Sprite"); renderer = spriteObject.GetComponent <SpriteRenderer>(); renderer.sprite = Util.ChooseFrom(variants); characters = new HashSet <GameObject>(); // randomize if (Util.Choose(true, true, true, true, true, true, false)) { transform.GetChild(0).localScale = Util.RandomRange(Vector3.one * 0.3f, Vector3.one * 0.8f); } else { transform.GetChild(0).localScale = Util.RandomRange(Vector3.one * 0.85f, Vector3.one * 2f); } if (Util.Choose(true, false)) { transform.GetChild(0).localScale = new Vector3(transform.localScale.x, transform.localScale.y, -transform.localScale.z); } Grass grs = this;//GetComponent<Grass>(); if (grs != null) { grs.SetOscillationOffset(Util.Random(180)); } }
public IEnumerator eat_food_task() { Human human = CreateHuman(); Node grassNode = Utils.NodeAt(_spawnPosition + new Vector2Int(0, 10)); Grass grass = Factory.Create <Grass>("grass", grassNode.Position); float defaultHungerLevel = human.HungerComponent.HungerLevel; Node targetNode = SearchEngine.FindNodeNear(grassNode, human.MotionComponent.Node); var task = new EatFoodTask(human, targetNode, grass); yield return(AddTaskAndWaitUntilFinished(task, human.CommandProcessor)); yield return(null); //check position if (human.MotionComponent.Node != targetNode) { Assert.Fail(); } //check hunger if (human.HungerComponent.HungerLevel == defaultHungerLevel) { Assert.Fail(); } //check food destroy if (grass.gameObject != null) { Assert.Fail(); } human.Die(); Assert.Pass(); }
public IEnumerator create_construction_plan() { foreach (string plan in constructionPlansToTest) { //yield return cancel_construction_plan(create_construction_plan(plan)); } Item item = Factory.Create <WoodLog>("wood log", _spawnPosition); foreach (string plan in constructionPlansToTest) { yield return(cancel_construction_plan(create_construction_plan(plan))); } item.Destroy(); Grass grass = Factory.Create <Grass>("grass", _spawnPosition); foreach (string plan in constructionPlansToTest) { yield return(cancel_construction_plan(create_construction_plan(plan))); } grass.Destroy(); Assert.Pass(); }
private int NearSpawn(Cell cell) { int[] wayX = { -1, 0, 1, 0 }; int[] wayY = { 0, 1, 0, -1 }; int x = cell.X; int y = cell.Y; int count = 0; for (int i = 0; i < wayX.Length; i++) { int newX = x + wayX[i]; int newY = y + wayY[i]; if (CheckBorder(newX, newY)) { if (Field[newX, newY].Entity.OfType <Grass>().FirstOrDefault() == null) { Grass newGrass = new Grass(newX, newY); Field[newX, newY].Entity.Add(newGrass); Entity.Add(newGrass); ChangedCell.Add(Field[newX, newY]); count++; } } } return(count); }
protected override void ReadData(ESPReader reader) { using (MemoryStream stream = new MemoryStream(reader.ReadBytes(size))) using (ESPReader subReader = new ESPReader(stream, reader.Plugin)) { try { Stone.ReadBinary(subReader); Dirt.ReadBinary(subReader); Grass.ReadBinary(subReader); Glass.ReadBinary(subReader); Metal.ReadBinary(subReader); Wood.ReadBinary(subReader); Organic.ReadBinary(subReader); Cloth.ReadBinary(subReader); Water.ReadBinary(subReader); HollowMetal.ReadBinary(subReader); OrganicBug.ReadBinary(subReader); OrganicGlow.ReadBinary(subReader); } catch { return; } } }
public Character copy() { Grass newGrass = new Grass(); newGrass.health = health / 2; return(newGrass); }
protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("ConcreteSolid", true, out subEle); subEle.Value = ConcreteSolid.ToHex(); ele.TryPathTo("ConcreteBroken", true, out subEle); subEle.Value = ConcreteBroken.ToHex(); ele.TryPathTo("MetalSolid", true, out subEle); subEle.Value = MetalSolid.ToHex(); ele.TryPathTo("MetalHollow", true, out subEle); subEle.Value = MetalHollow.ToHex(); ele.TryPathTo("MetalSheet", true, out subEle); subEle.Value = MetalSheet.ToHex(); ele.TryPathTo("Wood", true, out subEle); subEle.Value = Wood.ToHex(); ele.TryPathTo("Sand", true, out subEle); subEle.Value = Sand.ToHex(); ele.TryPathTo("Dirt", true, out subEle); subEle.Value = Dirt.ToHex(); ele.TryPathTo("Grass", true, out subEle); subEle.Value = Grass.ToHex(); ele.TryPathTo("Water", true, out subEle); subEle.Value = Water.ToHex(); }
public static void RScythe_performToolAction(ref Grass __instance, Tool t, Vector2 tileLocation) { if (t != null && t is MeleeWeapon && t.BaseName == "Radioactive Scythe") { int numberOfWeedsToDestroy2 = 4; if ((byte)__instance.grassType.Value == 6 && Game1.random.NextDouble() < 0.3) { numberOfWeedsToDestroy2 = 0; } __instance.numberOfWeeds.Value = (int)__instance.numberOfWeeds.Value - numberOfWeedsToDestroy2; if ((int)__instance.numberOfWeeds.Value <= 0) { Random obj = Game1.IsMultiplayer ? Game1.recentMultiplayerRandom : new Random((int)((float)(double)Game1.uniqueIDForThisGame + tileLocation.X * 1000f + tileLocation.Y * 11f)); double chance = 0.90; if (obj.NextDouble() < chance && (Game1.getLocationFromName("Farm") as Farm).tryToAddHay(1) == 0) { TemporaryAnimatedSprite tmpSprite = new TemporaryAnimatedSprite("Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 178, 16, 16), 750f, 1, 0, t.getLastFarmerToUse().Position - new Vector2(0f, 128f), flicker: false, flipped: false, t.getLastFarmerToUse().Position.Y / 10000f, 0.005f, Color.White, 4f, -0.005f, 0f, 0f); tmpSprite.motion.Y = -1f; tmpSprite.layerDepth = 1f - (float)Game1.random.Next(100) / 10000f; tmpSprite.delayBeforeAnimationStart = Game1.random.Next(350); Game1.addHUDMessage(new HUDMessage("Hay", 1, add: true, Color.LightGoldenrodYellow, new SObject(178, 1))); } } } }
// ------------ Methods to create unwalkable areas such as mountains and forests ------------\\ /// <summary> /// Replaces walls with mountains/forests/unwalkables /// </summary> // TODO: Include mountains private void replaceWalls() { Mountain mountain = new Mountain(); Grass grass = new Grass(); // Trying mountains first: for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] == WALL) { if (Shapes.CanFitShapeOver(WALL, new Point(x, y), Shapes.GetShape(Shapes.TRIPLEx3_LEFT), map)) { PlaceMountain(new Point(x, y), mountain.GetSpriteID(), GRASS2_SPRITEID, mountain.Shape); } } } } // Filling with forests where mountains do not fill. for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] == WALL) { FloodFillWall(new Point(x, y), FOREST_SPRITEID); } } } }
void OnCollisionEnter(Collision collision) { if (collision.transform.tag == GetFoodTag()) { if (collision.transform.tag == "Species1") { CreatureAgent targetAgent = collision.transform.GetComponent <CreatureAgent>(); if (targetAgent != null) { targetAgent.Eaten(); } } if (collision.transform.tag == "Grass") { Grass grass = collision.transform.GetComponent <Grass>(); if (grass != null) { grass.Eaten(); } } AddReward(1.0f); //Commenting out EndEpisode as the agents don't concern with consequences of after eating (i.e. other thing eats them) //EndEpisode(); } }
private static bool DrawPrefix(Grass __instance, int[] ___offset1, int[] ___offset2, int[] ___offset3, int[] ___offset4, int[] ___whichWeed, float ___shakeRotation, double[] ___shakeRandom, bool[] ___flip, SpriteBatch spriteBatch, Vector2 tileLocation) { if (__instance.modData.ContainsKey("AlternativeTextureName")) { var textureModel = AlternativeTextures.textureManager.GetSpecificTextureModel(__instance.modData["AlternativeTextureName"]); if (textureModel is null) { return(true); } var textureVariation = Int32.Parse(__instance.modData["AlternativeTextureVariation"]); if (textureVariation == -1 || AlternativeTextures.modConfig.IsTextureVariationDisabled(textureModel.GetId(), textureVariation)) { return(true); } var textureOffset = textureModel.GetTextureOffset(textureVariation); for (int i = 0; i < (int)__instance.numberOfWeeds; i++) { Vector2 pos = ((i != 4) ? (tileLocation * 64f + new Vector2((float)(i % 2 * 64 / 2 + ___offset3[i] * 4 - 4) + 30f, i / 2 * 64 / 2 + ___offset4[i] * 4 + 40)) : (tileLocation * 64f + new Vector2((float)(16 + ___offset1[i] * 4 - 4) + 30f, 16 + ___offset2[i] * 4 + 40))); spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, pos), new Rectangle(0, textureOffset, 15, 20), Color.White, ___shakeRotation / (float)(___shakeRandom[i] + 1.0), new Vector2(7.5f, 17.5f), 4f, ___flip[i] ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (pos.Y + 16f - 20f) / 10000f + pos.X / 1E+07f); } return(false); } return(true); }
public void TestAddGroundWhenEmptyCell() { var grass = new Grass(new Vector(0, 0)); emptyCell = emptyCell.AddGround(grass); Assert.AreEqual(emptyCell.Ground, grass); }
private static void GrassPostfix(Grass __instance) { var instanceName = $"{AlternativeTextureModel.TextureType.Grass}_{NAME_PREFIX}"; var instanceSeasonName = $"{instanceName}_{Game1.GetSeasonForLocation(__instance.currentLocation)}"; if (AlternativeTextures.textureManager.DoesObjectHaveAlternativeTexture(instanceName) && AlternativeTextures.textureManager.DoesObjectHaveAlternativeTexture(instanceSeasonName)) { var result = Game1.random.Next(2) > 0 ? AssignModData(__instance, instanceSeasonName, true) : AssignModData(__instance, instanceName, false); return; } else { if (AlternativeTextures.textureManager.DoesObjectHaveAlternativeTexture(instanceName)) { AssignModData(__instance, instanceName, false); return; } if (AlternativeTextures.textureManager.DoesObjectHaveAlternativeTexture(instanceSeasonName)) { AssignModData(__instance, instanceSeasonName, true); return; } } AssignDefaultModData(__instance, instanceSeasonName, true); }
public void explode() { // make an explosion GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); // get all enemies foreach (GameObject enemy in enemies) { // simulate enemies flying away from the explosion enemy.GetComponent <Animator>().SetBool("Exploded", true); enemy.GetComponent <Scroll>().updateSpeed(); } Vector3 pos = BalloonControlScript.Bottom.transform.position; pos.z = -3; if (GameControl.instance.distanceToGround() < 0.2f) { // if explosion occured close to the ground GameObject[] Grass1 = GameObject.FindGameObjectsWithTag("Grass Blade 1"); GameObject[] Grass2 = GameObject.FindGameObjectsWithTag("Grass Blade 2"); foreach (GameObject Grass in Grass1) { Grass.GetComponent <BurnGrass>().Burn(transform.position.x); } foreach (GameObject Grass in Grass2) { Grass.GetComponent <BurnGrass>().Burn(transform.position.x); } } GameObject Explosion = Instantiate(ExplosionPrefab, pos, Quaternion.Euler(-90, 0, 0)); // instantiate explosion Explosion.transform.parent = GameControl.instance.Ground.transform; Invoke("deactivate", Time.deltaTime); // deactivate the balloon }
public static bool placementAction_Prefix(StardewValley.Object __instance, ref bool __result, GameLocation location, int x, int y, Farmer who) { if (__instance.bigCraftable.Value || __instance is StardewValley.Objects.Furniture || (__instance.ParentSheetIndex != ModEntry.GrassStarterObjectId && __instance.ParentSheetIndex != ModEntry.QuickGrassStarterObjectId)) { return(true); } Vector2 placementTile = new Vector2(x / 64, y / 64); if (location.objects.ContainsKey(placementTile) || location.terrainFeatures.ContainsKey(placementTile)) { __result = false; return(false); } Grass grass = new Grass(1, ModEntry.config.shortGrassStarters ? 0 : 4); if (__instance.ParentSheetIndex == ModEntry.QuickGrassStarterObjectId) { grass.modData.Add(ModEntry.IsQuickModDataKey, ModEntry.IsQuickModDataValue); } location.terrainFeatures.Add(placementTile, grass); location.playSound("dirtyHit"); __result = true; return(false); }
public Map(int x, int y) { mapWidth = x; mapHeight = y; var rnd = new Random(); WorldMap = new ICell[mapWidth, mapHeight]; for (var i = 0; i < mapWidth; i++) { for (var j = 0; j < mapHeight; j++) { var value = rnd.Next(0, 100); if (value < 10) { WorldMap[i, j] = new Cave(); } else if (value > 60) { WorldMap[i, j] = new Forest(); } else { WorldMap[i, j] = new Grass(); } } } }
//трава public static Grass[] GetDetailsList(Util.Map.Location map) { Grass[] textures = new Grass[0]; switch (map) { case Util.Map.Location.Lorencia: textures = new Grass[]{ new Grass(){ file = "TileGrass01", dry = Color.yellow, healthy = Color.green, minHeight = 100, maxHeight = 120 } }; break; case Util.Map.Location.Devias: textures = new Grass[]{ new Grass(){ file = "TileGrass02", dry = Color.white, healthy = Color.white, minHeight = 50, maxHeight = 100 }, new Grass(){ file = "TileGrass02", dry = Color.white, healthy = Color.white, minHeight = 50, maxHeight = 100 } }; break; case Util.Map.Location.Noria: textures = new Grass[]{ new Grass(){ file = "TileGrass01", dry = Color.yellow, healthy = Color.green, minHeight = 150, maxHeight = 200 }, null, new Grass(){ file = "TileGrass03", dry = Color.yellow, healthy = Color.yellow, minHeight = 200, maxHeight = 300 } }; break; case Util.Map.Location.DareDevil: textures = new Grass[]{ new Grass(){ file = "TileGrass01", dry = Color.yellow, healthy = Color.yellow, minHeight = 150, maxHeight = 200 }, new Grass(){ file = "TileGrass02", dry = Color.white, healthy = Color.white, minHeight = 150, maxHeight = 200 }, new Grass(){ file = "TileGrass03", dry = Color.yellow, healthy = Color.yellow, minHeight = 200, maxHeight = 300 } }; break; case Util.Map.Location.Stadium: textures = new Grass[]{ new Grass(){ file = "TileGrass01", dry = Color.yellow, healthy = Color.yellow, minHeight = 100, maxHeight = 150 } }; break; case Util.Map.Location.Tarcan: textures = new Grass[]{ new Grass(){ file = "TileGrass01", dry = Color.gray, healthy = Color.gray, minHeight = 200, maxHeight = 300 }, null, new Grass(){ file = "TileGrass03", dry = Color.yellow, healthy = Color.yellow, minHeight = 200, maxHeight = 300 } }; break; } return textures; }
public Map(GameObject hexPrism, GameObject playerObj, int width = 10, int height = 10) { _hexPrism = hexPrism; _width = width; _height = height; _hexes = new HexElement[width, height]; for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { int type = Random.Range(0, 99) % 3; switch (type) { case 1: _hexes[i, j] = new Mud(); break; case 2: _hexes[i, j] = new Grass(); break; default: _hexes[i, j] = new Block(); break; } } } _player = new Player[1]; _player[0] = new Player(playerObj, 0, 0); }
public void GetObjectCoordinates_AllTypes() { var player = new Player(1, "Игрок №1", null); var map = new Map(null, null); var gameController = new GameController(map); var archer = new Archer(player) { X = 1, Y = 2 }; var archerCoordinates = gameController.GetObjectCoordinates(archer); Assert.AreEqual(1, archerCoordinates.X); Assert.AreEqual(2, archerCoordinates.Y); var catapult = new Catapult(player) { X = 3, Y = 4 }; var catapultCoordinates = gameController.GetObjectCoordinates(catapult); Assert.AreEqual(3, catapultCoordinates.X); Assert.AreEqual(4, catapultCoordinates.Y); var horseman = new Horseman(player) { X = 5, Y = 6 }; var horsemanCoordinates = gameController.GetObjectCoordinates(horseman); Assert.AreEqual(5, horsemanCoordinates.X); Assert.AreEqual(6, horsemanCoordinates.Y); var swordsman = new Swordsman(player) { X = 7, Y = 8 }; var swordsmanCoordinates = gameController.GetObjectCoordinates(swordsman); Assert.AreEqual(7, swordsmanCoordinates.X); Assert.AreEqual(8, swordsmanCoordinates.Y); var grass = new Grass { X = 9, Y = 10 }; var grassCoordinates = gameController.GetObjectCoordinates(grass); Assert.AreEqual(9, grassCoordinates.X); Assert.AreEqual(10, grassCoordinates.Y); var water = new Water { X = 11, Y = 12 }; var waterCoordinates = gameController.GetObjectCoordinates(water); Assert.AreEqual(11, waterCoordinates.X); Assert.AreEqual(12, waterCoordinates.Y); }
public Serperior(double health, string status) { name = "Serperior"; type1 = new Grass(); estimatedSpeed = 309; estimatedHealth = 309; estimatedAttack = 309; estimatedDefense = 309; estimatedSpAttk = 309; estimatedSpDef = 309; move1 = new Flamethrower(); move2 = new Flamethrower(); move3 = new Flamethrower(); move4 = new Flamethrower(); Initialize(name, health, status); }
internal Grass PastoQuePiso(Point rabbit) { int lugarX = rabbit.X / 2; int lugarY = rabbit.Y / 2; int aproximacion = (lugarX) + (width / 2 * (lugarY)); int ancho = 128; List <Grass> area = new List <Grass>(); if (lugarY == 127) { lugarY--; } if (lugarX == 127) { lugarX--; } for (int x = lugarX; x < Grass.PATCH_SIZE + lugarX; x++) { for (int y = lugarY * ancho; y < (lugarY + Grass.PATCH_SIZE) * ancho; y += ancho) { Grass a = Garden[y + x]; if (a.Position == rabbit) { return(a); } area.Add(a); } } return(area[0]); }
public Sceptile(double health, string status) { name = "Sceptile"; type1 = new Grass(); estimatedSpeed = 309; estimatedHealth = 309; estimatedAttack = 309; estimatedDefense = 309; estimatedSpAttk = 309; estimatedSpDef = 309; move1 = new Flamethrower(); move2 = new Flamethrower(); move3 = new Flamethrower(); move4 = new Flamethrower(); Initialize(name, health, status); }
public static bool doCollisionAction_Prefix(Grass __instance, float ___maxShake, float ___shakeRotation, Rectangle positionOfCollider, int speedOfCollision, Vector2 tileLocation, Character who, GameLocation location) { if (location != Game1.currentLocation) { return(false); } if (speedOfCollision > 0 && ___maxShake == 0f && positionOfCollider.Intersects(__instance.getBoundingBox(tileLocation))) { if ((who == null || !(who is FarmAnimal)) && Grass.grassSound != null && !Grass.grassSound.IsPlaying && Utility.isOnScreen(new Point((int)tileLocation.X, (int)tileLocation.Y), 2, location) && Game1.soundBank != null) { Grass.grassSound = Game1.soundBank.GetCue("grassyStep"); Grass.grassSound.Play(); } ModEntry.GrassShakeMethodInfo.Invoke(__instance, new object[] { (float)Math.PI / 8f / (float)((5 + Game1.player.addedSpeed) / speedOfCollision), (float)Math.PI / 80f / (float)((5 + Game1.player.addedSpeed) / speedOfCollision), (float)positionOfCollider.Center.X > tileLocation.X * 64f + 32f }); //this.shake((float)Math.PI / 8f / (float)((5 + Game1.player.addedSpeed) / speedOfCollision), (float)Math.PI / 80f / (float)((5 + Game1.player.addedSpeed) / speedOfCollision), (float)positionOfCollider.Center.X > tileLocation.X * 64f + 32f); } if (who is Farmer && Game1.player.CurrentTool != null && Game1.player.CurrentTool is MeleeWeapon && ((MeleeWeapon)Game1.player.CurrentTool).isOnSpecial && ((MeleeWeapon)Game1.player.CurrentTool).type.Value == 0 && Math.Abs(___shakeRotation) < 0.001f && __instance.performToolAction(Game1.player.CurrentTool, -1, tileLocation, location)) { Game1.currentLocation.terrainFeatures.Remove(tileLocation); } if (__instance.numberOfWeeds.Value > 0 && who is Farmer) { (who as Farmer).temporarySpeedBuff = -1f; if (__instance.grassType.Value == 6) { (who as Farmer).temporarySpeedBuff = -3f; } } return(false); }
// Update is called once per frame void Update() { int grass = Grass.getSeedsOrSaplings(typeof(Grass)); int shrub = Shrub.getSeedsOrSaplings(typeof(Shrub)); int leafTree = LeafTree.getSeedsOrSaplings(typeof(LeafTree)); int firTree = Grass.getSeedsOrSaplings(typeof(FirTree)); int cactus = Cactus.getSeedsOrSaplings(typeof(Cactus)); countGrass.text = grass.ToString(); countShrub.text = shrub.ToString(); countLeafTree.text = leafTree.ToString(); countFirTree.text = firTree.ToString(); countCactus.text = cactus.ToString(); if (grass == 0) { buttonGrass.GetComponent <Button>().interactable = false; } else { buttonGrass.GetComponent <Button>().interactable = true; } if (shrub == 0) { buttonShrub.GetComponent <Button>().interactable = false; } else { buttonShrub.GetComponent <Button>().interactable = true; } if (leafTree == 0) { buttonLeafTree.GetComponent <Button>().interactable = false; } else { buttonLeafTree.GetComponent <Button>().interactable = true; } if (firTree == 0) { buttonFirTree.GetComponent <Button>().interactable = false; } else { buttonFirTree.GetComponent <Button>().interactable = true; } if (cactus == 0) { buttonCactus.GetComponent <Button>().interactable = false; } else { buttonCactus.GetComponent <Button>().interactable = true; } }
public Chesnaught(double health, string status) { name = "Chesnaught"; type1 = new Grass(); type2 = new Fighting(); estimatedSpeed = 309; estimatedHealth = 309; estimatedAttack = 309; estimatedDefense = 309; estimatedSpAttk = 309; estimatedSpDef = 309; move1 = new Flamethrower(); move2 = new Flamethrower(); move3 = new Flamethrower(); move4 = new Flamethrower(); Initialize(name, health, status); }
void OnTriggerStay(Collider other) { Grass grass = other.GetComponent <Grass> (); grass.Mow(); HandleMowSpeed(grass); }
public Ferrothorn(double health, string status) { name = "Ferrothorn"; type1 = new Grass(); type2 = new Steel(); estimatedSpeed = 309; estimatedHealth = 309; estimatedAttack = 309; estimatedDefense = 309; estimatedSpAttk = 309; estimatedSpDef = 309; move1 = new Flamethrower(); move2 = new Flamethrower(); move3 = new Flamethrower(); move4 = new Flamethrower(); Initialize(name, health, status); }
public Venusaur(double health, string status) { name = "Venusaur"; type1 = new Grass(); type2 = new Poison(); estimatedSpeed = 309; estimatedHealth = 309; estimatedAttack = 309; estimatedDefense = 309; estimatedSpAttk = 309; estimatedSpDef = 309; move1 = new Flamethrower(); move2 = new Flamethrower(); move3 = new Flamethrower(); move4 = new Flamethrower(); Initialize(name, health, status); }
public void AddGrassView(Grass grass, GridLayout gridLayout) { GameObject instance; if (grassPool.transform.childCount > 0) instance = grassPool.transform.GetChild(0).gameObject; else instance = Object.Instantiate(grassPrototype) as GameObject; Random.seed = (grass.row * 7457) ^ (grass.column * 89); var grassTransform = instance.transform.GetChild(0).transform; grassTransform.localRotation = Quaternion.Euler(0f, 180f, Random.Range(0f, 360f) + grass.row * 97); var grassSize = Mathf.Clamp(grass.age * 0.2f, 0, 1); grassTransform.localScale = new Vector3(grassSize, grassSize, grassSize); gridLayout.AddItem(grass.row, grass.column, 0, instance, grassPool); }
protected override void ExecuteBirthCommand(string[] commandWords) { string organismType = commandWords[1]; string name = null; Point position = default(Point); switch (organismType) { case WolfType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Wolf newWolf = new Wolf(name, position); this.AddOrganism(newWolf); break; case LionType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Lion newLion = new Lion(name, position); this.AddOrganism(newLion); break; case GrassType: position = Point.Parse(commandWords[2]); Grass newGrass = new Grass(position); this.AddOrganism(newGrass); break; case BoarType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Boar newBoar = new Boar(name, position); this.AddOrganism(newBoar); break; case ZombieType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Zombie newZombie = new Zombie(name, position); this.AddOrganism(newZombie); break; default: base.ExecuteBirthCommand(commandWords); break; } }
/// <summary> /// Rez grass and ground cover /// </summary> /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param> /// <param name="scale">The size of the grass</param> /// <param name="rotation">The rotation of the grass</param> /// <param name="position">The position of the grass</param> /// <param name="grassType">The type of grass from the <seealso cref="Grass"/> enum</param> /// <param name="groupOwner">The <seealso cref="UUID"/> of the group to set the tree to, /// or UUID.Zero if no group is to be set</param> public void AddGrass(Simulator simulator, Vector3 scale, Quaternion rotation, Vector3 position, Grass grassType, UUID groupOwner) { ObjectAddPacket add = new ObjectAddPacket(); add.AgentData.AgentID = Client.Self.AgentID; add.AgentData.SessionID = Client.Self.SessionID; add.AgentData.GroupID = groupOwner; add.ObjectData.BypassRaycast = 1; add.ObjectData.Material = 3; add.ObjectData.PathCurve = 16; add.ObjectData.PCode = (byte)PCode.Grass; add.ObjectData.RayEnd = position; add.ObjectData.RayStart = position; add.ObjectData.RayTargetID = UUID.Zero; add.ObjectData.Rotation = rotation; add.ObjectData.Scale = scale; add.ObjectData.State = (byte)grassType; Client.Network.SendPacket(add, simulator); }
/** * Called when the script is loaded, before the game starts */ void Awake () { S = this; }
void createBlock(Vector3 blockPos) { int y = (int)blockPos.y; if (y < -128) return; // plain 2 int heightScale = 20; // 40+ float detailScale = 70.0f; int p_y = (int)(Mathf.PerlinNoise ((blockPos.x + this.seed)/detailScale, (blockPos.z + this.seed)/detailScale) * heightScale); Block block; if (y > p_y /*42*/) { return; // air } else if (y > 38) { block = new Snow (); } else if (y > 5 && y == p_y) { block = new Grass (); /* if (UnityEngine.Random.Range (0, 10) <= 2) { addBlock (blockPos + new Vector3 (0, 1, 0), new Fern ()); } else if (UnityEngine.Random.Range (0, 50) <= 2) { addBlock (blockPos + new Vector3 (0, 1, 0), new Rose ()); } */ } else if (y > 5) { block = new Dirt (); } else if (y == -128) { block = new BedRock (); } else { block = new Sand (); } addBlock(blockPos, block); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); device = graphics.GraphicsDevice; texturedEffect = Content.Load<Effect>("effect"); billboardGrassEffect = Content.Load<Effect>("billboardgrass"); grassEffect = Content.Load<Effect>("nonbillboardgrass"); skyEffect = Content.Load<Effect>("sky"); pointSpriteEffect = Content.Load<Effect>("PointSprite"); waterEffect = Content.Load<Effect>("watereffect"); shadowMapEffect = Content.Load<Effect>("shadowmap"); enviro = new Enviroment(); terrain = new TextureTerrain(this, enviro.map, enviro.texture); cam = new Camera(this,new Vector3(terrain.terrainWidth/2,15,terrain.terrainLength/2)); controls = new Controls(this); if (enviro.billboardedGrass) bbgrass = new BBGrass(this, terrain, enviro.grassTexture); else grass = new Grass(this, terrain, enviro.grassTexture); fps = new FrameRate(); text = new TextWriter(this, "font"); sky = new SkyBox(this, Vector3.Zero, "sky/dome2/dome"); car = new ModelLoader(this, "car/car", new Vector3(250, terrain.heightData[250, 230], 230), 1, 7); human = new ModelLoader(this, "human", new Vector3(terrain.terrainLength / 2, terrain.heightData[terrain.terrainLength / 2, terrain.terrainWidth / 2], terrain.terrainWidth / 2), 0.2f); moon = new PointSprites_Single(this, new Vector3(-10000, 20000, -10000), Content.Load<Texture2D>("moon"), 5000); snow = new PointSprites_Multi(this, cam.cameraPosition, Content.Load<Texture2D>("snow"), enviro.weatherParticles, 0.2f, rand); rain = new PointSprites_Multi(this, cam.cameraPosition, Content.Load<Texture2D>("rain"), enviro.weatherParticles, 0.2f, rand); water = new Water(this, terrain.terrainWidth / 10, terrain.terrainLength / 10, 10, Content.Load<Texture2D>("water"), Content.Load<Texture2D>("waterbump")); for (int i = 0; i < cloudTextures.Length; i++) { cloudTextures[i] = Content.Load<Texture2D>("clouds/cloud" + i); } clouds = new PointSprites_Single[500]; for (int i = 0; i < clouds.Length; i++) { clouds[i] = new PointSprites_Single(this, new Vector3(terrain.terrainLength / 2f + (float)(rand.NextDouble() * 2 - 1) * 10000, rand.Next(400, 600), terrain.terrainWidth / 2f + (float)(rand.NextDouble() * 2 - 1) * 10000), cloudTextures[rand.Next(0,5)], 1000); } shadowMap = new RenderTarget2D(device, 2048, 2048); }
// Use this for initialization void Start() { Application.targetFrameRate = 60; data = new Block[worldX, worldY, worldZ]; for (int x = 0; x < worldX; x++) { for (int z = 0; z < worldZ; z++) { int stone = PerlinNoise (x, 0, z, 10, 3, 1.2f); stone += PerlinNoise (x, 300, z, 20, 4, 0) + 10; int dirt = PerlinNoise (x, 100, z, 50, 6, 0) + 2; for (int y = 0; y < worldY; y++) { if (y <= stone) data[x,y,z] = new Rock(); else if (y < dirt+stone) data[x,y,z] = new Dirt(); else if (y == dirt+stone) data[x,y,z] = new Grass(); else data[x, y, z] = new Air(); } } } if (isClient) { Cursor.lockState = CursorLockMode.Locked; chunks = new Chunk[Mathf.FloorToInt(worldX/chunkSize), Mathf.FloorToInt(worldY/chunkSize), Mathf.FloorToInt(worldZ/chunkSize)]; GenerateChunks(); } }
public virtual void Visit(Grass grass) { }