void OnTriggerEnter(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); IAttackIgnored colProj = col.gameObject.GetComponent <IAttackIgnored>(); if (colProj == null) //check to see if we collided with another projectile. if so ignore { //Debug.Log("Col with non-proj, Proj is: " + friendly); if (enemy != null) { //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly); if (friendly != enemy.Friendly) { enemy.TakeDamage(dmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(dmg); } PlayAnim(col); //Debug.Log("Destroy due to hit non friend"); // Destroy(gameObject); } } else { PlayAnim(col); //Debug.Log("Destroy due to hit non stat char " + col.gameObject.name); // Destroy(gameObject); } } }
void OnCollisonStay(Collision col) { if (dmgTimer > 0.5f && !inUse) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); IAttackIgnored colProj = col.gameObject.GetComponent <IAttackIgnored>(); if (colProj == null) //check to see if we collided with another projectile. if so ignore { //Debug.Log("Col with non-proj, Proj is: " + friendly); if (enemy != null) { //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly); if (enemy.Friendly) { dmgTimer = 0f; enemy.TakeDamage(collideDmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(collideDmg); } } } } } }
protected virtual void OnTriggerStay(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); if (enemy != null) { if (friendly != enemy.Friendly) { if (enemyControl != null && Enemy != null) { foreach (TimedBuff tb in Enemy) { enemyControl.ApplyBuff(tb.ShallowClone()); } } } else { if (enemyControl != null && Friend != null) { foreach (TimedBuff tb in Friend) { enemyControl.ApplyBuff(tb.ShallowClone()); } } } } }
protected void Awake() { stats = GetComponent <StatBlock>(); controlStats = GetComponent <ControlStatBlock>(); bossClass = GetComponent <PlayerClass>(); player = GameObject.FindGameObjectWithTag("Player"); }
// Start is called before the first frame update void Start() { stats = GetComponent <StatBlock>(); controlStats = GetComponent <ControlStatBlock>(); PlayerClass pc = GetComponent <PlayerClass>(); abil = pc.abilities.Set[AbilName]; abil.cdRemain = 0f; UpdateStats(); }
// Start is called before the first frame update void Start() { for (int j = 0; j < transform.childCount; j++) { if (transform.GetChild(j).name.Equals("MainStats")) { statlist = transform.GetChild(j).gameObject.GetComponent <Text>(); } else if (transform.GetChild(j).name.Equals("Column1")) { column1 = transform.GetChild(j).gameObject.GetComponent <Text>(); } else if (transform.GetChild(j).name.Equals("Column2")) { column2 = transform.GetChild(j).gameObject.GetComponent <Text>(); } else if (transform.GetChild(j).name.Equals("Column3")) { column3 = transform.GetChild(j).gameObject.GetComponent <Text>(); } else if (transform.GetChild(j).name.Equals("LevelText")) { levelText = transform.GetChild(j).gameObject.GetComponent <Text>(); } else if (transform.GetChild(j).name.Equals("ClassText")) { classAgeText = transform.GetChild(j).gameObject.GetComponent <Text>(); } else if (transform.GetChild(j).name.Equals("NameText")) { nameText = transform.GetChild(j).gameObject.GetComponent <Text>(); } } GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Player"); if (gameObjects.Length > 0) { player = gameObjects[0].GetComponent <PlayerClass>(); textPlayerClass = gameObjects[0].GetComponent <TestPlayerClass>(); ControlStatBlock temp = gameObjects[0].GetComponent <ControlStatBlock>(); if (temp) { stats = temp; } } }
// Start is called before the first frame update void Start() { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).name.Equals("Column4")) { column4 = transform.GetChild(i).gameObject; } else if (transform.GetChild(i).name.Equals("ToolTip")) { toolTip = transform.GetChild(i).gameObject; } } toolTip.SetActive(false); storedAfflictions = new Dictionary <string, Affliction>(); stacks = new Dictionary <Affliction, int>(); afflictions = new List <Affliction>(); int count = column4.transform.childCount; storedAfflictionsObjects = new GameObject[count]; GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Player"); if (gameObjects.Length > 0) { player = gameObjects[0].GetComponent <ControlStatBlock>(); } for (int k = 0; k < column4.transform.childCount; k++) { storedAfflictionsObjects[k] = column4.transform.GetChild(k).gameObject; EventTrigger ev = storedAfflictionsObjects[k].GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerEnter; entry.callback.AddListener((eventData) => { OnHoverBuff((PointerEventData)eventData); }); ev.triggers.Add(entry); EventTrigger.Entry leave = new EventTrigger.Entry(); leave.eventID = EventTriggerType.PointerExit; leave.callback.AddListener((eventData) => { OnLeaveBuff((PointerEventData)eventData); }); ev.triggers.Add(leave); } previousSize = 0; currentSize = 0; }
void OnTriggerEnter(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); IAttackIgnored colProj = col.gameObject.GetComponent <IAttackIgnored>(); if (colProj == null) //check to see if we collided with another projectile. if so ignore { //Debug.Log("Col with non-proj, Proj is: " + friendly); if (enemy != null) { //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly); if (friendly != enemy.Friendly) { float dmgTaken = enemy.TakeDamage(dmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(dmg); } if (dmg.callback != null) { dmg.callback.Callback(dmgTaken); } if (destroyable) { OnDeath(); PlayAnim(col); Destroy(gameObject); } } } else { if (destroyable) { OnDeath(); PlayAnim(col); Destroy(gameObject); } } } }
private void Awake() { // NOTE: This Component's TakenPerks field gets its value from the // takenPerks field. That field must be loaded (the Load method must // have been called on it) before its Perks property will have a // non-null value in it. Therefore, the Load method of that PerkList is // called right here. This will work so long as no other Component in // the same scene as this Component requires the same PerkList to be // loaded for its Awake method. Normally, this PerkList would be // loaded in a GameState's Enter method but because a GameState's // Enter method is only guaranteed to run before any Component's Start // method, we must load it here. If any other Component's Awake method // in the same scene as this Component required this PerkList to be // loaded, it must have its Load method called on it in the GameState // just before the GameState that all those Components exist in. For // example, it would probably be loaded in HubGameState's Enter method. // If this logic (besides the takenPerks.Load() which could go in a // GameState's Enter method) was moved to Start, it may possibly work // but I don't know enough about the other Components that may rely on // PlayerClass's Awake method doing some set up that they need for // their own Start methods. // - Wesley takenPerks.Load(); // If takenPerks is empty, it means that we're either looking at the // null perk list or a new player perk list that is empy. if (takenPerks.Perks.Count <= 0) { // We have to make an entirely new list otherwise the null perk // list's list would be overwritten. TakenPerks = new List <PerkPrototype>(); } else { // Not a null perk list TakenPerks = takenPerks.Perks; } stats = GetComponent <ControlStatBlock>(); init = GetComponent <InitAbilities>(); }
protected override void OnTriggerStay(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); if (enemy != null) { if (friendly != enemy.Friendly) { enemy.TakeDamage(dmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(dmg); } Destroy(gameObject); } } else { Destroy(gameObject); } }
private void Start() { controlStatBlock = GetComponent <ControlStatBlock>(); }