private void Start() { #region Component Initialization AiData = GetComponent <AIData>(); Behaviour = AiData.GetComponent <MonsterBehavior>(); Checks = AiData.GetComponent <MonsterChecks>(); #endregion }
// Start is called before the first frame update void Start() { sfxPlayer = GetComponent <PlaySFXRandPitch>(); monsterChecks = gameObject.GetComponentInParent <MonsterChecks>(); if (monsterChecks == null) { Debug.Log("MonsterChecks is null"); } var circleCollider = GetComponent <CircleCollider2D>(); myCharData = GetComponent <CharacterData>(); //Physics2D.IgnoreCollision(circleCollider, GetComponent<CapsuleCollider2D>()); }
///Conga Line Functions public void BecomeLeader() { bool become = true; amLeader = false; foreach (GameObject Creature in AllCreatures) { #region Check if Creature Deleted if (Creature == null || Creature.tag == "Player") { continue; } #endregion MonsterChecks creatureCheck = Creature.GetComponent <MonsterChecks>(); if (creatureCheck.AmLeader()) { //Debug.Log(Creature.name + " is the Leader of " + this.name); // set leader specialLeader = creatureCheck.specialLeader; // set MY target to my leader this.SetSpecialTarget(creatureCheck.specialTarget); // set my leader's target to ME creatureCheck.SetSpecialTarget(this.gameObject); become = false; } else if (creatureCheck.specialLeader != null && specialTarget == this.gameObject) { // set leader GameObject lead = creatureCheck.specialLeader; creatureCheck = lead.GetComponent <MonsterChecks>(); // set leader specialLeader = creatureCheck.specialLeader; // set MY target to my leader //this.SetSpecialTarget(creatureCheck.specialTarget); // set my leader's target to ME creatureCheck.SetSpecialTarget(this.gameObject); become = false; } } // no one is a leader, so be the leader if (become) { //Debug.Log(this.name + " is the Leader now!!!"); amLeader = true; specialTarget = this.gameObject; specialLeader = this.gameObject; } }
protected void StopCharm() { // get protocols MonsterProtocols proto = characterData.getProtocol(); MonsterChecks check = characterData.getChecks(); // no leader check.ResetSpecials(); check.specialLeader = null; check.congaPosition = -1; // remove self from player's party PlayerController.instance.GetComponent <PlayerData>().party.Remove(gameObject); // initiate conga characterData.currentProtocol = AIData.Protocols.Lazy; Debug.Log("no longer CHARMED"); }
private void Start() { #region Initialize Components Behavior = GetComponent <MonsterBehavior>(); Protocol = GetComponent <MonsterProtocols>(); Checks = GetComponent <MonsterChecks>(); Curves = GetComponent <UtilityCurves>(); #endregion #region Initialize Data InitializeCharacterData(); InitializeNormalValues(); #endregion path = new List <TileNode>(); _vectors = new Dictionary <string, Vector2> { { "Player", new Vector2(0f, 0f) } }; }
private void Start() { #region Initialize #region GetComponents AiData = GetComponent <AIData>(); Checks = AiData.GetComponent <MonsterChecks>(); AnimatorBody = GetComponent <Animator>(); RigidBody = GetComponent <Rigidbody2D>(); controller = GetComponent <MonsterController>(); pathfinder = GetComponent <Pathfinder>(); flavor = GetComponent <FlavorInputManager>(); sfxPlayer = GetComponent <PlaySFX>(); #endregion ActionTimer = -1f; ActionTimerReset = 5f; ActionTimerVariance = 2f; ResetTimer = -1f; ResetTimerReset = 6f; ResetTimerVariance = 2f; ResetMovementBias(); #endregion }
protected void StartCharm(float time) { // get protocols //Debug.Log("should be CHARMED for " + time + " seconds"); MonsterProtocols proto = characterData.getProtocol(); MonsterChecks check = characterData.getChecks(); // initiate conga characterData.currentProtocol = AIData.Protocols.Conga; if (characterData.path != null) { characterData.path.Clear(); } // set leader to Soma check.specialLeader = PlayerController.instance.gameObject; // add self to player's party PlayerController.instance.GetComponent <PlayerData>().party.Add(gameObject); // get ready to stop it StartCoroutine(ExecuteCharm(time)); }
public GameObject FollowTheLeader() { // if i dont have a position in the conga if (congaPosition == -1) { int highestPos = -1; GameObject highestLeader = null; foreach (GameObject Creature in AllCreatures) { #region Check if Creature Deleted if (Creature == null || Creature.tag == "Player") { continue; } #endregion MonsterChecks check = Creature.GetComponent <MonsterChecks>(); int cp = check.congaPosition; if (cp > highestPos) { highestPos = cp; highestLeader = Creature; } } // set special target this.congaPosition = highestPos + 1; this.specialTarget = (this.congaPosition <= 0 ? specialLeader : highestLeader); } else { // if i already have a position int lowestPos = -1; int newPos = this.congaPosition; GameObject lowestLeader = this.specialLeader; foreach (GameObject Creature in AllCreatures) { #region Check if Creature Deleted if (Creature == null || Creature.tag == "Player") { continue; } #endregion MonsterChecks check = Creature.GetComponent <MonsterChecks>(); int cp = check.congaPosition; if (cp > lowestPos && cp < this.congaPosition) { lowestPos = cp; lowestLeader = Creature; } if (cp == newPos) { newPos++; } } // set special target this.congaPosition = newPos; this.specialTarget = lowestLeader; } // return special target //Debug.Log("position in conga = " + this.congaPosition); return(specialTarget); }