protected override void Awake() { base.Awake(); m_BeamStart = GameGlobals.AttachCheckComponent <SpriteRenderer>( Instantiate(beamStart, this.transform)); m_BeamStart.color = beamColor; m_BeamStart.transform.localScale = m_BeamStart.transform.localScale * beamWidth; m_DefaultStartFlipX = m_BeamStart.flipX; m_BeamMiddle = GameGlobals.AttachCheckComponent <SpriteRenderer>( Instantiate(beamMiddle, this.transform)); m_BeamMiddle.color = beamColor; m_BeamMiddle.transform.localScale = m_BeamMiddle.transform.localScale * beamWidth; m_BeamEnd = GameGlobals.AttachCheckComponent <SpriteRenderer>( Instantiate(beamEnd, this.transform)); m_BeamEnd.color = beamColor; m_BeamEnd.transform.localScale = m_BeamEnd.transform.localScale * beamWidth; m_DefaultEndFlipX = m_BeamEnd.flipX; m_TargetMask = ((Target == TargetType.AnyTarget) || otherTeamBlocks) ? BattleGlobals.GetBattleNPCLayerMask() : ((Target == TargetType.AlliedTargets) ? BattleGlobals.GetAlliedLayerMask(ParentSkill.SkillOwner.tag) : BattleGlobals.GetEnemyLayerMask(ParentSkill.SkillOwner.tag)); }
protected override void Start() { m_DefaultSpriteFlipX = ParentSkill.SkillSpriteRenderer.flipX; m_SkillDirection = (BattleGlobals.IsHeroTeamTag(ParentSkill.SkillOwner.tag)) ? Vector2.left : Vector2.right; base.Start(); }
/* * Check if this skill is configured to hit this BattleNPC * @param: b - BattleNPC beam says it hit * @returns: bool - true if configured to hit b, false if not configured to hit b */ private bool _checkValidDamage(BattleNPC hitNPC) { bool heroTeam = BattleGlobals.IsHeroTeamTag(hitNPC.tag); return(otherTeamValidTargets || (Target == TargetType.AnyTarget) || ((Target == TargetType.AlliedTargets) && heroTeam) || ((Target == TargetType.EnemyTargets) && !heroTeam)); }
public override void SetTarget(Target[] newTargets) { base.SetTarget(newTargets); if (!Homing) { ParentSkill.SkillOwner.NPCRigidBody2D.transform.rotation = BattleGlobals.LookAt(ParentSkill.SkillOwner.transform.parent.gameObject, NPCTargets[MELEE_ATTACK_PRIMARY_TARGET_INDEX].Focus.StartPuck.transform.position, ParentSkill.SkillOwner.tag); } }
/* * This is called separately because in multi-target spells it's better the skill set the target, * than the projectile query the skill for a target */ public void SetTargetAndDamage(BattleNPC target, float damageMultiplier) { m_mainTarget = target; m_ProjectileDamageMultiplier = damageMultiplier; if (m_ProjectileDamageMultiplier == 0) { m_ParentSkillByte.DeRegisterProjectile(this); } else { m_Rigid2d.transform.rotation = BattleGlobals.LookAt(this.gameObject, target.StartPuck.transform.position, this.tag); } }
// Use this for initialization void Awake() { m_Rigid2d = GameGlobals.AttachCheckComponent <Rigidbody2D>(this.gameObject); m_ParentSkillByte = GameGlobals.AttachCheckComponentParent <ProjectileAttackByte>(this.gameObject); m_SpriteRenderer = GameGlobals.AttachCheckComponent <SpriteRenderer>(this.gameObject); this.tag = (BattleGlobals.IsHeroTeamTag(m_ParentSkillByte.ParentSkill.SkillOwner.tag)) ? BattleGlobals.TAG_FOR_HERO_PROJ : BattleGlobals.TAG_FOR_ENEMY_PROJ; this.name = GameGlobals.TrimCloneFromName(this.name) + "(" + m_ParentSkillByte.ParentSkill.SkillOwner + ")"; // If the object is homing, this does not matter m_ProjDirection = (this.gameObject.CompareTag(BattleGlobals.TAG_FOR_HERO_PROJ)) ? Vector2.left : Vector2.right; m_mainTarget = null; }
public override void DoByte() { Rigidbody2D parentRigid = ParentSkill.SkillOwner.NPCRigidBody2D; ApplyOnCastBuffs(); // Whenever we're roughly where we started float absoluteDistance = Mathf.Abs(parentRigid.transform.position.sqrMagnitude - m_TargetPosition.sqrMagnitude); if (absoluteDistance < V3_EQUALS_THRESHOLD) { ParentSkill.SkillOwner.FlipBattleNPCSpriteX(); ParentSkill.AdvanceToNextByte(); } else { BattleGlobals.HomingMovement(parentRigid, m_TargetPosition, (ParentSkill.SkillOwner.NPCMoveSpeedMultiplier.GetBuffAffectedValue() * ByteSpeed)); } }
// Update is called once per frame void Update() { if (m_ParentSkillByte.Homing) { BattleGlobals.HomingMovement(m_Rigid2d, m_mainTarget.transform.position, m_ParentSkillByte.ParentSkill.SkillOwner.NPCProjSpeedMultiplier.GetBuffAffectedValue() * m_ParentSkillByte.ByteSpeed); } else { BattleGlobals.NonHomingMovement(m_Rigid2d, m_ProjDirection * m_ParentSkillByte.ParentSkill.SkillOwner.NPCProjSpeedMultiplier.GetBuffAffectedValue() * m_ParentSkillByte.ByteSpeed); // When we are out of sight, we missed if (!m_SpriteRenderer.isVisible) { m_ParentSkillByte.DeRegisterProjectile(this); } } }
// This handles the logic for the projectile "connecting" with it's target public void OnTriggerEnter2D(Collider2D collision) { BattleNPC colNPC = collision.gameObject.GetComponentInChildren <BattleNPC>(); if (colNPC != null) { if (!m_ParentSkillByte.Blockable) { if ((m_mainTarget != null) && (m_mainTarget == colNPC)) { if (m_ProjectileDamageMultiplier != 0) { m_ParentSkillByte.OnSkillByteHit(colNPC, m_ProjectileDamageMultiplier); } m_ParentSkillByte.DeRegisterProjectile(this); } } else { SkillByte.TargetType targetType = m_ParentSkillByte.Target; bool isValidTarget = (targetType == SkillByte.TargetType.AnyTarget) || ((targetType == SkillByte.TargetType.AlliedTargets) && !BattleGlobals.IsHostileToTag(this.tag, colNPC.tag)) || ((targetType == SkillByte.TargetType.EnemyTargets) && BattleGlobals.IsHostileToTag(this.tag, colNPC.tag)); if (colNPC.Alive && isValidTarget) { if (m_ProjectileDamageMultiplier != 0) { m_ParentSkillByte.OnSkillByteHit(colNPC, m_ProjectileDamageMultiplier); } m_ParentSkillByte.DeRegisterProjectile(this); } } } }
public virtual void OnTriggerEnter2D(Collider2D collision) { BattleNPC colNPC = collision.gameObject.GetComponentInChildren <BattleNPC>(); if (colNPC != null) { if (!Blockable) { int targetIndex = CheckValidTarget(colNPC); if ((targetIndex != -1)) { OnSkillByteHit(NPCTargets[targetIndex].Focus, NPCTargets[targetIndex].Multiplier); } } else { if (colNPC.Alive && BattleGlobals.IsHostileToTag(ParentSkill.SkillOwner.tag, colNPC.tag)) { OnSkillByteHit(colNPC); } } } }
public override void DoByte() { AnimateOwner(BattleGlobals.ANIMATE_NPC_ATTACK); ApplyOnCastBuffs(); if (Homing) { BattleGlobals.HomingMovement(ParentSkill.SkillOwner.NPCRigidBody2D, NPCTargets[MELEE_ATTACK_PRIMARY_TARGET_INDEX].Focus.transform.position, (ParentSkill.SkillOwner.NPCMoveSpeedMultiplier.GetBuffAffectedValue() * ByteSpeed)); } else { BattleGlobals.NonHomingMovement(ParentSkill.SkillOwner.NPCRigidBody2D, m_SkillDirection * (NON_HOMING_SPEED_MULTIPLIER * ParentSkill.SkillOwner.NPCMoveSpeedMultiplier.GetBuffAffectedValue() * ByteSpeed)); if (!ParentSkill.SkillOwner.NPCSpriteRender.isVisible) { OnSkillByteHit(null); } } }
public BattleGround(IEnumerable <BattleCharacter> battleCharacters) { _teamA = new List <BattleCharacter>(); _teamB = new List <BattleCharacter>(); foreach (var battleCharacter in battleCharacters) { battleCharacter.JoinBattleGround(this); switch (battleCharacter.BelongTeam) { case BelongTeam.A: _teamA.Add(battleCharacter); break; case BelongTeam.B: _teamB.Add(battleCharacter); break; default: throw new ArgumentOutOfRangeException(); } } BattleGlobals = new BattleGlobals(_teamA.Count, _teamB.Count); }
protected void Awake() { m_BuffSpriteMaterial = BattleGlobals.GetBuffSpriteMaterial(); m_BuffSpriteOrder = BattleGlobals.GetBuffOrderInLayer(); }