public void SetAsMembers(Actor[] newMembers) { foreach(Actor actor in newMembers) { SetTeam(actor, this); } }
public static GameObject SpawnRagdoll(Actor actor, HumanBodyBones originPart, HumanBodyBones keptPart) { GameObject obj = Object.Instantiate(RagdollSpawner.rd); Animator anim = obj.GetComponent<Animator>(); SyncBones(actor.transform.Find("ScientistSkeleton"), obj.transform.Find("ScientistSkeleton")); anim.GetBoneTransform(originPart).localScale = ScaleDown * Vector3.one; anim.GetBoneTransform(keptPart).localScale = ScaleUp * Vector3.one; return obj; }
private void AddMember(Actor actor) { Actor[] newMembers = new Actor[_members.Length + 1]; for(int i = 0; i < _members.Length; i++) { newMembers[i] = _members[i]; } newMembers[newMembers.Length - 1] = actor; _members = newMembers; actor.team = this; actor.enemyTeam = this.enemyTeam; }
private void RemoveMember(Actor actor) { int index = Array.IndexOf(_members, actor); if (index < 0) return; Actor[] newMembers = new Actor[_members.Length - 1]; for(int i = 0; i < index; i++) { newMembers[i] = _members[i]; } for(int j = index + 1; j < _members.Length; j++) { newMembers[j - 1] = _members[j]; } _members = newMembers; actor.team = NONE; actor.enemyTeam = NONE; }
public static void SetTeam(Actor actor, Team team) { actor.team.RemoveMember(actor); team.AddMember(actor); }
public static bool isSameTeam(Actor a, Actor b) { return a.team != NONE && b.team != NONE && a.team == b.team; }
public ActorConfig(Actor owner) { this.owner = owner; }
public Observer(Actor actor) { this.owner = actor; _lastPositions = new Vector3[trackAmount]; _lastRotations = new Quaternion[trackAmount]; }
public static void RandomizeModel(Actor actor) { ModelDesigner design = actor.modelDesign; design.SetColor(BodyPart.HAIR, RandomColor(hairColors)); design.SetColor(BodyPart.EYES, RandomColor(eyeColors)); design.SetColor(BodyPart.CLOTHES, RandomColor(clothesColors)); design.SetColor(BodyPart.EQUIPMENT, RandomColor(equipmentColors)); design.SetColor(BodyPart.SKIN, RandomColor(skinColors)); design.SetColor(BodyPart.BEAM, RandomColor(beamColors)); design.SetBald(Random.value > 0.7f); design.SetClothing(RandomTexture()); }
/// <summary> /// Reevaluates the current target to be the closest enemy to the owner /// </summary> private void DecideTarget() { if(owner.enemyTeam.members.Length == 0) { Debug.Log("No enemies found."); return; } Actor[] enemies = owner.enemyTeam.members; currentTarget = owner.FindClosestEnemy() ?? enemies[0]; float closest = DistanceTo(currentTarget); }
/// <summary> /// Calculates the distance of the owner to a specified actor. /// </summary> /// <param name="actor">the enemy to measure against</param> /// <returns>the distance between owner and the actor</returns> public float DistanceTo(Actor actor) { return Vector3.Distance(owner.transform.position, actor.transform.position); }
public static float Distance(Actor a, Actor b) { return Vector3.Distance(a.transform.position, b.transform.position); }