// Use this for initialization void Start() { if(thoughtMan==null) thoughtMan = GameObject.Find("ThoughtManager").GetComponent<ThoughtManager>(); myAI = GetComponent<AI> (); InitIdeas(); }
public void SpawnSpeech(ThoughtManager.Idea i) { if(currentSpeech) { Destroy(currentSpeech.gameObject); currentSpeech = null; } currentSpeech = GameObject.Instantiate(SpeechPrefab, Player.player.transform.position + transform.up * 1f, Quaternion.identity) as GameObject; Speech s = currentSpeech.GetComponent<Speech>(); currentSpeech.AddComponent<PlayerSpeech> ().idea = i; currentSpeech.name = "Player's " + currentSpeech.name; FollowObject follow = currentSpeech.AddComponent<FollowObject>(); follow.follow = Player.player.gameObject; follow.normalOffset = new Vector3(0, 1.5f, 0); follow.rotateSpeed = 0; follow.moveSpeed = 5; s.transform.FindChild("Bubble").GetComponent<SpriteRenderer>().color = Player.player.GetComponent<Human>().Body.color; ThoughtManager.Idea ideaToUse = i; Sprite spriteToUse = ideaToUse.sprite; Color colorToUse = ideaToUse.color; colorToUse = Color.Lerp(colorToUse, Color.white, 0.4f); s.InitChildSprites(spriteToUse, colorToUse); }
public void AddThought(ThoughtManager.Idea idea) { Ideas.Add(idea); if(Mathf.Abs(idea.starsign - myAI.Starsign)<myAI.starsignDiff) { GoodIdeas.Add(idea); } else// if((1-Mathf.Abs(idea.starsign - Starsign))<starsignDiff) { BadIdeas.Add(idea); } }
public void ThinkAbout(ThoughtManager.Idea idea) { if (!thoughts.Ideas.Contains (idea)) { thoughts.AddThought(idea); } if (IsThisAGoodIdea(idea)) { float happinessAdd = (1 - Mathf.Abs(Starsign - idea.starsign)) * 0.5f; thoughts.GoodIdeas.Add(idea); UpdateOpinion(happinessAdd); } if (IsThisABadIdea(idea)) { float angryAdd = Mathf.Abs(Starsign - idea.starsign) * 0.5f; thoughts.BadIdeas.Add(idea); UpdateOpinion(-angryAdd); } }
void InitButton(Vector3 position, Vector2 size, ThoughtManager.Idea idea, Sprite sprite, Color color) { GameObject newButton = new GameObject(sprite.name, typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Button), typeof(CoolAnimation)); newButton.transform.position = position; newButton.GetComponent<RectTransform>().sizeDelta = size; newButton.GetComponent<Image>().sprite = sprite; newButton.GetComponent<Image>().color = color; float randFreq = Random.Range(1,2); if(Random.value>0.5f) randFreq = -randFreq; newButton.GetComponent<CoolAnimation>().Frequency = randFreq; newButton.GetComponent<CoolAnimation>().RotationAxis = new Vector3(0,0,1); newButton.GetComponent<CoolAnimation>().RotationSpeed = 20f; newButton.transform.SetParent(this.transform, true); newButton.GetComponent<Button>().onClick.AddListener(() => Say(idea)); }
public void Say(ThoughtManager.Idea i) { SpawnSpeech(i); }
bool IsThisAGoodIdea(ThoughtManager.Idea idea) { return thoughts.GoodIdeas.Contains (idea); }
// Use this for initialization void Awake() { thoughtMan = this; InitIdeas(); }