public override void onPlay() { Game game = Game.game; game.currentState = Game.GameStates.Cinematic; game.allowEnemySpawn = false; GameObject prefab = Resources.Load("Prefabs/Enemies/Blood_Steel") as GameObject; BasicEnemy enemy = Game.game.spawnEnemy(prefab); GameObject go = enemy.gameObject; Animation anim = go.AddComponent <Animation>(); enemy.mustNotifyDeath = true; enemy.prefab = prefab; enemy.currentFacing = SoulAvenger.Character.FACING.LEFT; AnimationClip clip = Resources.Load("Cinematics/Quest13/Blood_Steel_Appears") as AnimationClip; anim.AddClip(clip, "cinematic"); anim.Play("cinematic"); SoulAvenger.Character hero = GameObject.Find("Hero").GetComponent <SoulAvenger.Character>(); hero.currentFacing = SoulAvenger.Character.FACING.RIGHT; }
public override void fillInfo(SoulAvenger.Character character) { target = character.currentTarget; transform.localScale = character.transform.localScale; forward.x = transform.localScale.x; base.fillInfo(character); }
public void OnHitCollider(Collider other) { bool hasHit = false; SoulAvenger.Character defender = other.GetComponent <SoulAvenger.Character>(); if (defender == null && other.transform.parent != null) { defender = other.transform.parent.GetComponent <SoulAvenger.Character>(); } if (defender is Hero) { hasHit = true; defender.onAttackFrom(this.attack.character, attack); Game.game.inflictDamage(defender, attack, critical); } if (hasHit) { if (destroyOnHit) { destroyAmmo(); } else { OnCollision collisionCb = GetComponent <OnCollision>(); if (collisionCb) { collisionCb.OnTriggerEnterCallback = null; collisionCb.OnTriggerStayCallback = null; } } } }
public void OnHitCollider(Collider other) { if (hasHitTarget) { return; } if (attack == null || attack.character == null || attack.character.currentAttack != attack) { return; } if (!attack.character.isAlive()) { return; } SoulAvenger.Character defender = other.GetComponent <SoulAvenger.Character>(); if (defender == null && other.transform.parent != null) { defender = other.transform.parent.GetComponent <SoulAvenger.Character>(); } if (defender is Hero) { hasHitTarget = true; defender.onAttackFrom(this.attack.character, attack); Game.game.inflictDamage(defender, attack, critical); } }
public void OnHitCollider(Collider other) { if (!processHit) { return; } SoulAvenger.Character defender = other.GetComponent <SoulAvenger.Character>(); if (defender == null && other.transform.parent != null) { defender = other.transform.parent.GetComponent <SoulAvenger.Character>(); } if (defender is Hero) { BoxCollider myCollider = GetComponent <BoxCollider>(); Bounds myBounds = new Bounds(myCollider.bounds.center - new Vector3(0, height, 0), myCollider.bounds.size); Bounds feetBounds = defender.getFeet().collider.bounds; if (myBounds.Intersects(feetBounds)) { defender.onAttackFrom(this.attack.character, attack); Game.game.inflictDamage(defender, attack, critical); processHit = false; } } }
void processMouseInput() { SoulAvenger.Character newTarget = pickTargetUsingMouse(); if (newTarget == currentTarget && newTarget != null) { return; } Vector2 mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); if (newTarget != null) { if (Hud.getHud().quickPotionState == Hud.QUICKPOTION_STATE.INPLACE) { Hud.getHud().toogleQuickPotions(null); } if (!currentAttack || currentAttack.currentState != Attack.AttackStates.ATTACKING) { SetTargetToAttack(newTarget); } else { nextTarget = newTarget; } } else if (Game.game.screenPosInPlayableArea(mousePos)) { if (Hud.getHud().quickPotionState == Hud.QUICKPOTION_STATE.INPLACE) { Hud.getHud().toogleQuickPotions(null); } nextTarget = null; Vector3 newWorldPos = Game.game.screenPosToWorldPos(mousePos); Vector3 feetPos = getFeetPosition(); feetPos.z = newWorldPos.z; if (shouldMove(feetPos, newWorldPos)) { if (currentAttack != null) { currentAttack.onEndAttack(); } currentTarget = null; Game.game.showEnemyTarget(null); hasEndAttackChain = true; currentTargetHasBeenAttacked = false; mouseFollowTarget = newWorldPos; //this false then true is needed, do not remove it followingMouse = false; followingMouse = true; hasReachTarget = false; } } }
public void SetTargetToAttack(SoulAvenger.Character newTarget) { currentTarget = newTarget; currentTargetHasBeenAttacked = isFirstInTail(newTarget); hasEndAttackChain = true; hasReachTarget = false; nextTarget = null; }
public override void onAttackFrom(SoulAvenger.Character c, Attack attack) { numHits++; if (currentAttack != null) { currentAttack.onAttackFrom(c); } }
public bool IsInAttackRange() { SoulAvenger.Character me = character; SoulAvenger.Character tg = me.currentTarget; BoxCollider myCollider = me.getFeet().GetComponent <BoxCollider>(); BoxCollider tgCollider = tg.getFeet().GetComponent <BoxCollider>(); return(SoulAvenger.CollisionDetection.Test2D(myCollider, tgCollider)); }
public override void fillInfo(SoulAvenger.Character character) { base.fillInfo(character); OnCollision collisionCb = GetComponent <OnCollision>(); if (collisionCb) { collisionCb.OnTriggerEnterCallback = OnHitCollider; collisionCb.OnTriggerStayCallback = OnHitCollider; } }
public void OnHitCollider(Collider other) { SoulAvenger.Character c = other.gameObject.GetComponent <SoulAvenger.Character>(); if (c == null || hitList.Contains(c) || (character is Hero && c is Hero) || (character is BasicEnemy && c is BasicEnemy)) { return; } c.onAttackFrom(character, this); Game.game.inflictDamage(c, this, 0.0f); hitList.Add(c); }
public override void fillInfo(SoulAvenger.Character character) { base.fillInfo(character); Vector3 right = new Vector3(character.transform.localScale.x, 0.0f, 0.0f); origin = character.getAmmoBorn().position; origin.z = -1.0f; destiny = origin + right * distanceToTravel; chara = character; }
public override void TStart() { character = gameObject.GetComponent <SoulAvenger.Character>(); character.registerAttack(this); currentState = AttackStates.IDLE; tk2dAnimatedSprite anim = character.getSprite(); if (anim.GetClipIdByName("spawn") != -1) { Game.game.playSound(character.spawningSound); character.spawningComplete = false; character.changeAnimation("spawn", delegate(tk2dAnimatedSprite sprite, int clipId){ character.spawningComplete = true; character.changeAnimation("idle"); }); } }
public override void onAttackFrom(SoulAvenger.Character c) { if ((character as BasicEnemy) == null || (c as Hero) == null) { return; } BasicEnemy enemy = character as BasicEnemy; Hero hero = c as Hero; if (hero.currentAttack != null && hero.currentAttack.currentState == Attack.AttackStates.ATTACKING && !hero.isFirstInTail(enemy)) { hero.moveToTailTip(enemy); } }
public SoulAvenger.Character pickTargetUsingMouse() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 10.0f, 1 << 9)) { SoulAvenger.Character newTarget = (SoulAvenger.Character)hitInfo.collider.gameObject.transform.parent.gameObject.GetComponent <SoulAvenger.Character>(); if (newTarget != null && newTarget != currentTarget && newTarget.isAlive() && newTarget.canBeAttacked /* && Game.game.canBePicked(newTarget)*/) { return(newTarget); } } return(null); }
public override void TStart() { character = gameObject.GetComponent <SoulAvenger.Character>(); character.changeAnimation("forceField"); target = character.currentTarget; //if(target!=null) { Vector3 pos = (target != null)?target.getFeetPosition():character.getFeetPosition(); pos.z = -0.5f; GameObject thunder = Instantiate(Resources.Load("Prefabs/Effects/Thunder"), pos, Quaternion.identity) as GameObject; thunder.GetComponent <tk2dAnimatedSprite>().animationCompleteDelegate = onFxComplete; } base.TStart(); }
bool characterIsGettingCloseTo(SoulAvenger.Character movingCharacter, SoulAvenger.Character fixedCharacter) { Vector2 moveDir = character.currentTarget.getMovementDirection(); if (moveDir == Vector2.zero) { return(false); } Vector3 myDiff3 = character.getFeetPosition() - character.currentTarget.getFeetPosition(); Vector2 myDiff = new Vector2(myDiff3.x, myDiff3.y); myDiff.Normalize(); float dot = Vector2.Dot(myDiff, moveDir); return(dot >= 0.0f); }
public override void TUpdate() { base.TUpdate(); if (runningTutorial && Input.GetMouseButtonDown(0)) { Hero h = Game.game.playableCharacter as Hero; SoulAvenger.Character newTarget = h.pickTargetUsingMouse(); if (newTarget != null) { h.currentTarget = newTarget; runningTutorial = false; Game.game.currentState = Game.GameStates.InGame; foreach (BasicEnemy enemy in BasicEnemy.sEnemies) { Transform parent = enemy.gameObject.transform.FindChild("HandTutorial"); if (parent == null) { parent = enemy.gameObject.transform; } Transform hand = parent.FindChild("Hand"); if (hand != null) { Destroy(hand.gameObject); } } Game.game.pauseButtonEnabled = true; #pragma warning disable 162 if (Game.demoMode) { Game.game.healingPotionEnabled = true; Game.game.magicPotionEnabled = true; Game.game.quickChestEnabled = true; } #pragma warning restore 162 } } }
public override void fillInfo(SoulAvenger.Character character) { base.fillInfo(character); origin = character.getAmmoBorn().position; destiny = origin + -character.transform.right * 10.0f; height = character.getAmmoBorn().position.y - character.getFeet().position.y; this.transform.localScale = new Vector3(character.transform.localScale.x, 1.0f, 1.0f); OnCollision collisionCb = GetComponent <OnCollision>(); if (collisionCb) { collisionCb.OnTriggerEnterCallback = OnHitCollider; collisionCb.OnTriggerStayCallback = OnHitCollider; } }
public void OnHitCollider(Collider other) { if (hitTimer < minTimeBetweenHits) { return; } SoulAvenger.Character c = other.gameObject.GetComponent <SoulAvenger.Character>(); if (c == null || (character is Hero && c is Hero) || (character is BasicEnemy && c is BasicEnemy)) { return; } if (SoulAvenger.CollisionDetection.Test2D(c.getFeet().GetComponent <BoxCollider>(), character.getFeet().GetComponent <BoxCollider>())) { c.onAttackFrom(character, this); Game.game.inflictDamage(c, this, 0.0f); hitTimer = 0.0f; } }
public override void onAttackFrom(SoulAvenger.Character c, Attack attack) { if (!c.canBeAttacked || followingMouse) { return; } if (currentTarget == null) { currentTarget = c; currentTargetHasBeenAttacked = false; } else if (currentTarget != c) { if (hasEndAttackChain && !(attack is Ranged) && (!currentTarget.feetsAreInAValidAttackArea() || !currentTargetHasBeenAttacked)) { currentTarget = c; currentTargetHasBeenAttacked = false; } } }
public void OnHitCollider(Collider other) { SoulAvenger.Character defender = other.GetComponent <SoulAvenger.Character>(); if (defender == null && other.transform.parent != null) { defender = other.transform.parent.GetComponent <SoulAvenger.Character>(); } if (defender is Hero) { bool hasCollide = !useHeight; if (useHeight) { Vector3 arrowFeet = transform.position; arrowFeet.y -= height; Bounds feetBounds = defender.getFeet().collider.bounds; Vector3 rayOrigin = arrowFeet; rayOrigin.y += 0.5f; rayOrigin.z = feetBounds.center.z; Ray ray = new Ray(rayOrigin, Vector3.down); float distance = 10000.0f; if (feetBounds.IntersectRay(ray, out distance)) { if (distance < 1.0f) { hasCollide = true; } } } if (hasCollide) { defender.onAttackFrom(this.attack.character, attack); Game.game.inflictDamage(defender, attack, critical); destroyAmmo(); } } }
public virtual void fillInfo(SoulAvenger.Character character) { attack = character.currentAttack; critical = (float)character.getCriticalPoints() / 100.0f; }
public override void fillInfo(SoulAvenger.Character character) { target = character.currentTarget; height = character.getAmmoBorn().position.y - character.getFeet().position.y; base.fillInfo(character); }
public override void onEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum) { if (frame.eventInfo.ToLower() == "evaluateAttack".ToLower()) { if (currentTarget != null) { currentAttack.EvaluateAttack(); currentTargetHasBeenAttacked = true; attackChainIndex++; } } else if (frame.eventInfo.ToLower() == "endChainIfNeeded".ToLower()) { if (nextTarget != null && nextTarget.isAlive()) { attackChainIndex = 0; currentTargetHasBeenAttacked = true; currentTarget = nextTarget; currentAttack.onEndAttack(); hasEndAttackChain = true; nextTarget = null; } else if (currentTarget == null || !currentTarget.isAlive()) { attackChainIndex = 0; currentTargetHasBeenAttacked = true; currentTarget = null; currentAttack.onEndAttack(); hasEndAttackChain = true; } else if (abortAttackChain) { abortAttackChain = false; attackChainIndex = 0; currentTargetHasBeenAttacked = true; currentAttack.onEndAttack(); hasEndAttackChain = true; } } else if (frame.eventInfo.ToLower() == "endAttack".ToLower()) { attackChainIndex = 0; currentAttack.onEndAttack(); hasEndAttackChain = true; abortAttackChain = false; if (nextTarget != null && nextTarget.isAlive()) { currentTarget = nextTarget; nextTarget = null; } } else if (frame.eventInfo.ToLower() == "onSkillCompleted".ToLower()) { usingSkill = false; changeAnimation("idle"); } else if (frame.eventInfo.ToLower() == "startCharging".ToLower()) { SkCharge charge = GetComponent <SkCharge>(); if (charge != null) { charge.startCharging(); } } else if (frame.eventInfo.ToLower() == "stopCharging".ToLower()) { SkCharge charge = GetComponent <SkCharge>(); if (charge != null) { charge.stopCharging(); } } }
public bool isInAttackRange(SoulAvenger.Character other) { return(distanceToAttack > Vector3.Distance(this.transform.position, other.getFeetPosition())); }
public override void TStart() { character = GetComponent <SoulAvenger.Character>(); }
public virtual void onAttackFrom(SoulAvenger.Character c) { }