public void Activate(Critter newCritter) { if(hex){ critter = newCritter; UpdateInfo(); } }
public static List<Sprite> PopulateTokenSpriteOptions(Critter.locomotionType[] locomotions) { List<Sprite> finalSpriteList = new List<Sprite>(); Sprite[] currentList; string itemLocation = ""; foreach (Critter.locomotionType locoType in locomotions) { itemLocation = CheckTokenImageLocationString(locoType); currentList = Resources.LoadAll<Sprite>(itemLocation); currentList = pUnlocksControl.GenerateUnlockedSpriteList(currentList); foreach (Sprite item in currentList) { if (!finalSpriteList.Contains(item)) { finalSpriteList.Add(item); } } } finalSpriteList.TrimExcess(); return finalSpriteList; }
public static void Init(Critter ghost, bool firstTime) { if(firstTime) { // set max possible HP ghost.Stat[Stats.MaxLife] = 9999; ghost.Stat[Stats.CurrentHP] = 9999; // and armor class ghost.Stat[Stats.ArmorClass] = 90; } // syncronize ghost actual state with var value if(ghost.Cond == Cond.Dead && GhostState == State.Alive ) { ghost.ToLife(); } else if(ghost.Cond != Cond.Dead && GhostState == State.Dead) { ghost.ToDead(Anim2.DeadBurnRun, null); } ghost.Attacked += _GhostAttacked; ghost.Dead += _GhostDead; ghost.Respawn += (self, e) => GhostState = State.Alive; ghost.Stealing += _GhostStealing; }
private void SetCritter() { if (!critter) { critter = FindObjectOfType<Player>().GetCritter(); } }
public void Activate(Critter newCritter, Hex newHab) { critter = newCritter; habitat = newHab; warnControl = FindObjectOfType<WarningsController>(); }
void Awake () { crit = GetComponent<Critter>(); if (sfx == null) sfx = GameObject.Find("Audio/AudioSFX").GetComponent<AudioSource>(); }
public void SetCritterTransformArray(Critter sourceCritter) { critter = sourceCritter; critterDecorationsTest.critter = sourceCritter; critterSegmentTransforms = new SegmentTransform[sourceCritter.critterSegmentList.Count]; // grab numSegments from Critter for(int i = 0; i < sourceCritter.critterSegmentList.Count; i++) { SegmentTransform segmentTransform; segmentTransform.PX = sourceCritter.critterSegmentList[i].transform.position.x; segmentTransform.PY = sourceCritter.critterSegmentList[i].transform.position.y; segmentTransform.PZ = sourceCritter.critterSegmentList[i].transform.position.z; segmentTransform.RX = sourceCritter.critterSegmentList[i].transform.rotation.x; segmentTransform.RY = sourceCritter.critterSegmentList[i].transform.rotation.y; segmentTransform.RZ = sourceCritter.critterSegmentList[i].transform.rotation.z; segmentTransform.RW = sourceCritter.critterSegmentList[i].transform.rotation.w; segmentTransform.SX = sourceCritter.critterSegmentList[i].transform.localScale.x / 2f; segmentTransform.SY = sourceCritter.critterSegmentList[i].transform.localScale.y / 2f; segmentTransform.SZ = sourceCritter.critterSegmentList[i].transform.localScale.z / 2f; critterSegmentTransforms[i] = segmentTransform; } //Debug.Log("SetCritterTransformArray numSegments: " + critterSegmentTransforms.Length + ", BoundingBox: " + sourceCritter.BoundingBoxMinCorner.ToString() + " -> " + sourceCritter.BoundingBoxMaxCorner.ToString()); // Largest boundingBox dimension determines cellResolution? GlobalBoundingBoxDimensions = (sourceCritter.BoundingBoxMaxCorner - sourceCritter.BoundingBoxMinCorner) * 1.15f; // buffer amount GlobalBoundingBoxOffset = (sourceCritter.BoundingBoxMaxCorner + sourceCritter.BoundingBoxMinCorner) / 2f; int approxChunksPerDimension = 5; float avgRadius = (GlobalBoundingBoxDimensions.x + GlobalBoundingBoxDimensions.y + GlobalBoundingBoxDimensions.z) / 3f; float chunkSize = avgRadius / (float)approxChunksPerDimension; float cellSize = chunkSize / 8f; cellResolution = cellSize; }
/// <summary> /// Mutates a critter /// </summary> /// <param name="child"> /// The critter that is to be mutated. /// </param> /// <returns> /// A mutated critter. /// </returns> public Critter Mutate(Critter child) { var rand = Random.GetInstance(); double u1 = rand.NextDouble(); // these are uniform(0,1) random doubles double u2 = rand.NextDouble(); double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2); // random no int crossoverWeight = (int)Tools.Clamp(10 * randStdNormal, -30, 30); child.DepartureTime = this.properties.DepartureTime.AddMinutes(crossoverWeight); Assert.That(child.DepartureTime != default(DateTime)); var random = Random.GetInstance(); List<NodeWrapper<INetworkNode>> nodes = child.Route; if (nodes.Count == 1) { return child; } int startIndex = random.Next(0, nodes.Count - 2); int endIndex = random.Next(startIndex + 1, nodes.Count - 1); NodeWrapper<INetworkNode> begin = nodes[startIndex]; NodeWrapper<INetworkNode> end = nodes[endIndex]; Route newSegment = this.properties.RouteGenerator.Generate( begin.Node, end.Node); var newRoute = new Route(Guid.NewGuid().GetHashCode()); newRoute.AddRange(nodes.GetRange(0, startIndex)); newRoute.AddRange(newSegment); newRoute.AddRange(nodes.GetRange(endIndex + 1, nodes.Count - 1 - endIndex)); return new Critter((Route)newRoute.Clone(), new Fitness()) { DepartureTime = child.DepartureTime }; // return child; }
public void Activate(Critter newCritter) { critter = newCritter; if (critter) { PopulateLocalCritterList(); } }
public void Activate() { if (!playerCritter) { playerCritter = FindObjectOfType<Player>().GetCritter(); } mainPanel.SetActive(true); subPanel.Activate(); gameObject.SetActive(true); }
public static Sprite[] GetTokenSpriteOptions(Critter critter) { Critter.locomotionType[] locomotions = critter.GetLocomotion(); tokenSpriteOptions = PopulateTokenSpriteOptions(locomotions).ToArray(); return tokenSpriteOptions; }
public void Activate(Critter critter, Adaptation.BodySlot newType) { gameObject.SetActive(true); InitializeSlots(critter, newType); PopulatePanel(); }
public void Activate(Critter newCritter) { critter = newCritter; slotIcons = GetComponentsInChildren<UISlot>(); InitializeSlots(critter, slotType); }
void Start() { critterGen = FindObjectOfType<CritterGenerator>(); myCritter = gameObject.GetComponent<Critter>(); cloneCritter = false; splitTimer = timerResetVal; currentTurn = TurnTimer.currentTurn; }
public void Activate(Critter newCritter, Hex newHab, WarningChecker.warningType newType, Sprite newSprite, Color32 color) { icon = GetComponentsInChildren<Image>()[1]; type = newType; icon.sprite = newSprite; icon.color = color; }
public void Activate(Critter newCritter) { critter = newCritter; size = critter.GetSize(); scale = .4f + (.05f * size); Vector3 scaleVect = new Vector3(scale, scale, 1); gameObject.GetComponent<RectTransform>().localScale = scaleVect; }
public IList<Item> GetItems(Critter critter) { var container = GetContainer (critter, false); if (container == null) return new List<Item> (0); var itemArray = new ItemArray (); container.GetItems (0, itemArray); return new List<Item> (itemArray); }
public void Activate() { gameObject.SetActive(true); target = null; mainPanel.SetActive(false); subPanel.gameObject.SetActive(false); StartCoroutine("ActivateMainPanel"); }
/// <summary> /// Applies crossover to 2 parents to create a child. /// </summary> /// <param name="first"> /// The first parent of the crossover. /// </param> /// <param name="second"> /// The second parent of the crossover. /// </param> /// <returns> /// If the operation is successful then the result is returned, otherwise null. /// </returns> public Critter[] Crossover(Critter first, Critter second) { var random = Random.GetInstance(); List<NodeWrapper<INetworkNode>> firstNodes = first.Route; List<NodeWrapper<INetworkNode>> secondNodes = second.Route; var crossoverPoints = new List<KeyValuePair<int, int>>(); for (int i = 0; i < firstNodes.Count; i++) { for (int j = 0; j < secondNodes.Count; j++) { if (firstNodes[i].Node.Equals(secondNodes[j].Node)) { crossoverPoints.Add(new KeyValuePair<int, int>(i, j)); break; } } } if (crossoverPoints.Count == 0) { // throw new Exception("StandardBreeder.cs: The crossover points are undefined."); // crossoverPoints.Add(new KeyValuePair<int, int>(random.Next(firstNodes.Count - 1), random.Next(secondNodes.Count - 1))); return null; } var firstChild = new Route(-1); var secondChild = new Route(-1); KeyValuePair<int, int> crossoverPoint = crossoverPoints[random.Next(crossoverPoints.Count - 1)]; firstChild.AddRange(firstNodes.GetRange(0, crossoverPoint.Key)); firstChild.AddRange(secondNodes.GetRange(crossoverPoint.Value, secondNodes.Count - crossoverPoint.Value)); secondChild.AddRange(secondNodes.GetRange(0, crossoverPoint.Value)); secondChild.AddRange(firstNodes.GetRange(crossoverPoint.Key, firstNodes.Count - crossoverPoint.Key)); var output = new[] { new Critter((Route)firstChild.Clone(), new Fitness()), new Critter((Route)secondChild.Clone(), new Fitness()) }; output[0].DepartureTime = second.DepartureTime; output[1].DepartureTime = first.DepartureTime; Assert.That(output[0].DepartureTime != default(DateTime)); Assert.That(output[1].DepartureTime != default(DateTime)); if (output == null || output[0] == null || output[1] == null) { throw new Exception("StandardBreeder.cs: One or more decendants of crossover are null."); } return output; }
public void Activate() { gameObject.SetActive(true); if(!critter){ critter = FindObjectOfType<Player>().GetCritter(); } if(critter){ habList.Populate(critter); } }
private void GoToPosition(Critter npc, NpcPlane plane, ushort hexX, ushort hexY, ushort dir) { var walkPlane = Global.CreatePlane (); walkPlane.Type = PlaneType.Walk; walkPlane.Run = true; walkPlane.Walk_Cut = 0; walkPlane.Walk_HexX = hexX; walkPlane.Walk_HexY = hexY; walkPlane.Walk_Dir = (Direction)dir; plane.SetChild (walkPlane); }
public void PutItems(Critter critter, IList<Item> items) { var container = GetContainer (critter, true); if (container == null) return; var itemArray = new ItemArray (); itemArray.AddRange (items); Global.MoveItems (itemArray, container, 0); }
public void GenerateLine(Critter target, float threat) { SetCritter(target); SetDietIcons(critter); SetValue(threat); critterIcon.sprite = critterSprite; critterIcon.color = iconColor; scoreText.text = value; scoreText.color = textColor; PrintDietIcons(); }
private void CritterCheck() { if (!critter) { Player player = FindObjectOfType<Player>(); if (player) { critter = player.GetCritter(); } } }
private bool TryToAttack(Critter critterToAttack) { if (!Check(critterToAttack)) return false; //TODO: maybe check if not already attacking the critter if (specialAttackFlags != 0) GetCritter().Mode[Modes.SpecialAttackFlags] = specialAttackFlags; NpcPlanes.AddAttackPlane(GetCritter(), Priorities.Attack, critterToAttack, true); return true; }
void Update() { critter = uiControl.ViewSelectedCritter(); if(critter){ critterSprite = critter.GetTokenSprite(); color = critter.GetTokenColor(); } this.GetComponent<Image>().sprite = critterSprite; this.GetComponent<Image>().color = color; }
public static void Init(Critter boy) { boy.Stealing += (self, e) => { if (e.Success && Global.Random(0, 5) == 0) boy.SayMsg(Say.Norm, TextMsg.Text, Str.StealFail); }; boy.Respawn += (self, e) => { if (boy.CountItem(Pid.RADIO) < 1) boy.AddItem(Pid.RADIO, 1); }; }
public void Populate(Critter critter) { if(!uiControl){ uiControl = FindObjectOfType<UIController>(); buttons = new List<HexButton>(); GenerateGrid(); } target = critter; foreach(HexButton item in buttons){ item.Activate(target); } }
public static Critter _BoyInit(IntPtr ptr, bool firstTime) { Critter boy = new Critter(ptr); Init(boy); // Создаем событие, где мальчик зазывает покупать у него рации if(Global.CreateTimeEvent(Time.After(Time.GameMinute((uint)Global.Random(10, 50))), e_Announcement, boy.Id, false ) == 0) Global.Log( "Time event Announcement create fail, {0}", Global.GetLastError() ); // Создаем событие, где мальчик приветсвует с добрым утром if(Global.CreateTimeEvent( Time.GetNearFullSecond( 0, 0, 0, 8, 0, 0 ), e_AnnouncementMorning, boy.Id, false ) == 0) Global.Log( "Time event AnnouncementMorning create fail, {0}", Global.GetLastError() ); return boy; }
public static Critter _VirginInit(IntPtr ptr, bool firstTime) { var virgin = new Critter(ptr); virgin.Idle += _VirginIdle; virgin.Talk += _VirginTalk; if(Global.CreateTimeEvent(Time.After(Time.GameMinute((uint)Global.Random(1, 60) * 60)), e_Check, virgin.Id, false) == 0 ) Global.Log( "Time event Check create fail, {0}", Global.GetLastError() ); virgin.Stat[Stats.Var0] = 0; virgin.Stat[Stats.Var1] = 0; return virgin; }
public override void NotifyCloseToFood(int x, int y) { Critter.Direction = Critter.GetDirectionTo(x, y); }
public override void Awake(StateMachine stateMachine) { _critter = stateMachine.GetComponent <Critter>(); }
public Neighbour(Critter critter) { this.WorldPosition = critter.Transform.origin; this.LocalHeading = -critter.Transform.basis.z; }
public override bool BehaviourTrigger(Critter _critter) { Initialize(); return(base.BehaviourTrigger(_critter)); }
public object Post(Critter critter, CritterCaptureCommand captureCommand) { critter.IsCaptured = true; return(critter); }
public object Post(Critter critter, CritterExplodeCommand explodeCommand) { critter.Name = explodeCommand.Noops + " EXPLOSION!"; return(critter); }
public float MatrixAffinity(Critter player, Critter enemy) { float multiplier = affinityMatrix[player.getAffinity(), enemy.getAffinity()]; return(multiplier); }
public CritterWrapper(Critter item) => GetBaseType = item;
internal static string GetCritterIdFrom(Critter critter) { int bframe = critter.baseFrame; if (critter is Cloud) { bframe = -2; } if (critter is Frog frog) { bframe = Mod.instance.Helper.Reflection.GetField <bool>(frog, "waterLeaper").GetValue() ? -3 : -4; } if (critter is OverheadParrot parrot) { bframe = -10 - parrot.sourceRect.Y; } if (critter is CalderaMonkey monkey) { bframe = -100; } switch (bframe) { case -10: case -34: return("GreenParrot"); case -58: case -82: return("BlueParrot"); case -100: return("Monkey"); case -3: return("GreenFrog"); case -4: return("OliveFrog"); case -2: return("Cloud"); case -1: return("Firefly"); case 0: return("Seagull"); case 14: return("Crow"); case 25: return("BrownBird"); case 45: return("BlueBird"); case 54: return("GrayRabbit"); case 74: return("WhiteRabbit"); case 60: return("Squirrel"); case 83: return("Owl"); case 115: return("PurpleBird"); case 125: return("RedBird"); case 160: return("SpringButterflyPalePink"); case 163: return("SpringButterflyWhite"); case 166: return("SpringButterflyPurple"); case 180: return("SpringButterflyMagenta"); case 183: return("SpringButterflyYellow"); case 186: return("SpringButterflyPink"); case 128: return("SummerButterflyBlue"); case 132: return("SummerButterflyRed"); case 136: return("SummerButterflyYellow"); case 148: return("SummerButterflyGreen"); case 152: return("SummerButterflyPink"); case 156: return("SummerButterflyOrange"); case 320: return("WoodPecker"); case 364: return("OrangeIslandButterfly"); case 368: return("PinkIslandButterfly"); case 372: return("SunsetTropicalButterfly"); case 376: return("TropicalButterfly"); } return("???"); }
private void Start() { //get refrence to the critter component critter = GetComponent <Critter>(); }
private void Awake() { critter = GetComponent <Critter>(); maxHealth = critter.data.health; }