CircleOption ChoseOptionBasedOnPosition() { Vector2 pose = Vector2.zero; if (Vector2.Distance(Input.mousePosition, mosePoseOnClick) < Screen.height / 6) { pose = new Vector2(0, 0); } else { pose = (-mosePoseOnClick + Input.mousePosition).normalized; } CircleOption curOption = options[0]; float minDistance = 10; float curDistance; for (int i = 0; i < options.Count; i++) { curDistance = Vector2.Distance(options[i].pose, pose); if (curDistance < minDistance) { minDistance = curDistance; curOption = options[i]; } } return(curOption); }
void PleaceOption(Vector2 pose, CircleOption option) { option.body = Instantiate(optionPref, optionsBodysHolder.transform.position + (Vector3)pose, Quaternion.identity); option.body.transform.parent = optionsBodysHolder.transform; option.body.GetComponent <SpriteRenderer>().sprite = option.sprite; option.pose = pose; }
public void PrepareSkill(CircleOption option) { if (preperedSkill) { preperedSkill.active = true; } preparedSkillIcon.sprite = option.sprite; preperedSkill = option; preperedSkill.active = false; }
void ChooseAndHide() { CircleOption option = ChoseOptionBasedOnPosition(); if (commands.state == MonkayCommands.MonkayState.onBack && option.name != Action.none && option.name != Action.yell) { queueCommands.Add(GetOption(Action.onBack)); } queueCommands.Add(option); ShowOptions(false); }
void PleaceOptions() { int optionsCount = options.Count - 1; float step = 0; int indexer = 0; for (int i = 1; i < options.Count; i++) { CircleOption option = options[i]; step = 2 * Mathf.PI / optionsCount * indexer; PleaceOption(new Vector2(Mathf.Sin(step), Mathf.Cos(step)) * circleRadius, option); indexer++; } }
void Light(CircleOption option) { foreach (CircleOption opt in options) { if (opt.active) { opt.body.GetComponent <SpriteRenderer>().color = Color.white; } else { opt.body.GetComponent <SpriteRenderer>().color = Color.gray; } } if (option.active) { option.body.GetComponent <SpriteRenderer>().color = Color.green; } }
public void ExecuiteOption(CircleOption option) { if (!option.active) { return; } //if() switch (option.name) { case Action.wait: commands.Wait(); break; case Action.follow: commands.FollowMe(); break; case Action.go: commands.GO(); break; case Action.onBack: commands.OnBack(); break; case Action.switchChar: commands.SwitchCharacters(); break; case Action.yell: commands.Yell(); break; default: skills.PrepareSkill(option); break; } }