// Update is called once per frame void Update() { if (Input.GetButtonDown("Interact")) { Collider[] nearby = Physics.OverlapSphere(transform.position, 2, 1 << 8); //Debug.Log(nearby.Length); foreach (var near in nearby) { var person = near.GetComponent <TownPerson>(); if (person.following) { continue; } if (onDeckPerson) { // check for match with nearby guy if (onDeckPerson.IsMyMatch(person)) { TownPerson front = null; if (happyPeople.Count > 0) { front = happyPeople[happyPeople.Count - 1]; } happyPeople.Add(onDeckPerson); happyPeople.Add(person); onDeckPerson.face.SetHappy(true); onDeckPerson.PlaySound(true); person.face.SetHappy(true); person.FollowBehind(transform); onDeckPerson.FollowBehind(person.transform); if (front) { front.FollowBehind(onDeckPerson.transform); } } else { onDeckPerson.UnFollow(); onDeckPerson.PlaySound(false); } onDeckPerson = null; } else { person.FollowAtSide(transform); onDeckPerson = person; } break; } } }
public Character CreateCharacter(charactertype type) { Character character = null; if (type.Equals(charactertype.orc)) { character = new Orc(); } else if (type.Equals(charactertype.sorcerer)) { character = new Sorcerer(); } else if (type.Equals(charactertype.townperson)) { character = new TownPerson(); } else if (type.Equals(charactertype.warrior)) { character = new Warrior(); } return character; }
public Character CreateCharacter(charactertype type) { Character character = null; if (type.Equals(charactertype.orc)) { character = new Orc(); } else if (type.Equals(charactertype.sorcerer)) { character = new Sorcerer(); } else if (type.Equals(charactertype.townperson)) { character = new TownPerson(); } else if (type.Equals(charactertype.warrior)) { character = new Warrior(); } return(character); }
public bool IsMyMatch(TownPerson other) { return(gameObject.name.Split(' ')[0] == other.gameObject.name.Split(' ')[0]); }