예제 #1
0
 /// <summary>
 /// 普通攻擊
 /// </summary>
 public void NormalAttack()
 {
     LockedAgent.GetDetails <DetailsBase>().HitPoint -= _agent.GetDetails <TroopDetails>().Damage;
     if (LockedAgent.GetDetails <DetailsBase>().Type == AgentType.Troop &&
         _agent.GetDetails <TroopDetails>().Damage >= LockedAgent.GetDetails <TroopDetails>().KnockBack)
     {
         LockedAgent.GetComponent <AlertAbility>().KnockBack = true;
     }
 }
예제 #2
0
 public void DoAction(CoreBase trainBy)
 {
     if (trainBy.Details.Level < 10)
     {
         trainBy.GetDetails <BuildingDetails>().Upgrade();
     }
 }
예제 #3
0
 public void Heal()
 {
     foreach (Collider2D b in GetComponent <BoxCollider2D>().OverlapAll())
     {
         if (b.tag == GameArgs.Building || b.tag == GameArgs.Troop)
         {
             CoreBase agent = b.GetComponent <CoreBase>();
             if (agent.Team == TargetTeam)
             {
                 agent.GetDetails <DetailsBase>().HitPoint += Damage;
                 if (agent.GetDetails <DetailsBase>().HitPoint > agent.GetDetails <DetailsBase>().MaxHitPoint)
                 {
                     agent.GetDetails <DetailsBase>().HitPoint = agent.GetDetails <DetailsBase>().MaxHitPoint;
                 }
             }
         }
     }
 }
예제 #4
0
 public void Attack()
 {
     foreach (Collider2D b in GetComponent <BoxCollider2D>().OverlapAll())
     {
         if (b.tag == GameArgs.Building || b.tag == GameArgs.Troop || b.tag == GameArgs.Shield)
         {
             CoreBase agent = b.GetComponent <CoreBase>();
             if (agent.Team == TargetTeam)
             {
                 agent.GetDetails <DetailsBase>().HitPoint -= Damage;
                 if (agent.GetDetails <DetailsBase>().Type == AgentType.Troop && Damage >= agent.GetDetails <TroopDetails>().KnockBack)
                 {
                     agent.GetComponent <AlertAbility>().KnockBack = true;
                 }
             }
         }
     }
 }
예제 #5
0
    /// <summary>
    /// 普通攻擊
    /// </summary>
    public void NormalHeal()
    {
        DetailsBase la = LockedAgent.GetDetails <DetailsBase>();

        la.HitPoint += _agent.GetDetails <TroopDetails>().Damage;
        if (la.HitPoint > la.MaxHitPoint)
        {
            la.HitPoint = la.MaxHitPoint;
        }
    }
예제 #6
0
 /// <summary>
 /// 產生護盾
 /// </summary>
 public void MakeShield()
 {
     if (ShieldTime <= 0)
     {
         if (Shield != null)
         {
             Shield.GetDetails <TroopDetails>().HitPoint = 0;
         }
         Shield                  = Instantiate(InstantiateObject).GetComponent <CoreBase>();
         Shield.Team             = _agent.Team;
         Shield.gameObject.layer = 16;
         TroopDetails det = Shield.GetComponent <CoreBase>().GetDetails <TroopDetails>();
         det.Level = _agent.GetDetails <DetailsBase>().Level;
         float scale = Mathf.Pow(det.GrowthRate, det.Level - 1);
         det.MaxHitPoint           = det.HitPoint = (int)(det.MaxHitPoint * scale);
         det.Damage                = (int)(det.Damage * scale);
         det.KnockBack             = (int)(det.KnockBack * scale);
         det.Gold                  = (int)(det.Gold * scale);
         Shield.transform.position = transform.position;
         ShieldTime                = ShieldCoolDown;
     }
 }
예제 #7
0
 public override bool Triggers()
 {
     //RaycastHit2D hit = Physics2D.Raycast(_rayOrigin, _agent.Direction, _agent.GetDetails<TroopDetails>().HitRange * 1.5f, _agent.EnemyLayerMask);
     //if (!hit) return false;
     RaycastHit2D[] hits;
     if (_agent.Team == AgentTeam.Ally)
     {
         hits = (
             from a in Physics2D.RaycastAll(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange * 10, 1 << (int)_agent.Team)
             where a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().HitPoint < a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().MaxHitPoint
             orderby a.transform.position.x descending
             select a).ToArray();
     }
     else
     {
         hits = (
             from a in Physics2D.RaycastAll(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange * 10, 1 << (int)_agent.Team)
             where a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().HitPoint < a.transform.GetComponent <CoreBase>().GetDetails <DetailsBase>().MaxHitPoint
             orderby a.transform.position.x
             select a).ToArray();
     }
     if (hits.Length == 0)
     {
         hits = (from a in Physics2D.RaycastAll(_rayOrigin, _agent.Direction, _agent.GetDetails <TroopDetails>().HitRange * 10, 1 << (int)_agent.Team)
                 orderby a.transform.position.x
                 select a).ToArray();
     }
     foreach (RaycastHit2D h in hits)
     {
         if (h.transform.gameObject == gameObject)
         {
             continue;
         }
         CoreBase agent = h.transform.transform.GetComponent <CoreBase>();
         if (agent.GetDetails <DetailsBase>().Type == AgentType.Building)
         {
             continue;
         }
         if (Naukri.NMath.Gap(_agent.transform.position.x, agent.transform.position.x) > _agent.GetDetails <TroopDetails>().HitRange)
         {
             return(false);
         }
         else
         {
             LockedAgent = agent;
             return(true);
         }
     }
     return(false);
 }
예제 #8
0
    public void ChangePanelInfo(int identify)
    {
        Debug.Log(identify);
        GameObject temp = Instantiate(Prefabs.Troop[identify] as GameObject);

        temp.transform.position = new Vector3(9999999, 9999999, 9999999);
        CoreBase target = temp.GetComponent <CoreBase>();

        Chicken.overrideSprite = target.GetComponent <SpriteRenderer>().sprite;
        Chicken.SetNativeSize();
        //Chicken.transform.localScale = new Vector3(0.5f * target.transform.localScale.x, 0.5f * target.transform.localScale.y, 1);
        var det = target.GetDetails <TroopDetails>();

        Name.text       = det.Name;
        Comment.text    = det.Comment;
        HitPoint.text   = det.HitPoint.ToString();
        GrowthRate.text = det.GrowthRate.ToString();
        Damage.text     = det.Damage.ToString();
        HitRange.text   = det.KnockBack.ToString();
        Speed.text      = det.Speed.ToString();
        KnockBack.text  = det.KnockBack.ToString();
        Destroy(temp);
    }