/// <summary>
 /// 初始化坦克攻击组件
 /// </summary>
 private void InitTankAttack(TankManager tank, TankModuleHead head)
 {
     TankModuleHead.AttackProperties properties = head.attackProperties;
     tank.tankAttack = tank.GetComponentInChildren <TankAttack>();
     if (tank.tankAttack == null)
     {
         Debug.LogError("Tank Head Need 'TankAttack' Component!");
         return;
     }
     tank.stateController.attackManager = tank.tankAttack;
     tank.tankAttack.forceSlider        = tank.GetComponent <TankManager>().aimSlider;
     tank.tankAttack.chargingClip       = properties.chargingClip;
     tank.tankAttack.fireClip           = properties.fireClip;
     tank.tankAttack.ResetSliderValue(properties.minLaunchForce, properties.maxLaunchForce, properties.maxChargeTime);
     tank.tankAttack.damage       = properties.damage;
     tank.tankAttack.coolDownTime = properties.coolDownTime;
     tank.tankAttack.CDTimer.Reset(properties.coolDownTime);
     System.Type type = tank.tankAttack.GetType();
     if (type == typeof(TankAttackShooting))
     {
         TankAttackShooting attack = tank.tankAttack as TankAttackShooting;
         //attack.ammoPool = head.attackProperties.ammoPool;
         attack.ammoSpawnPoint = new Point(head.ammoSpawnPoint);
     }
     else if (type == typeof(TankAttackBoxing))
     {
         TankAttackBoxing attack = tank.tankAttack as TankAttackBoxing;
         attack.springBoxingGlove = headObj.GetComponentInChildren <SpringBoxingGloveManager>();
         attack.launchDistance    = new AnimationCurve(new Keyframe(0, 0, 0, 3.5f), new Keyframe(0.3f, 1, 0, 0));
     }
 }
 /// <summary>
 /// 清除信息
 /// </summary>
 public void Clean()
 {
     target               = null;
     targetAmmoModule     = null;
     targetHeadModule     = null;
     previewImage.enabled = false;
     previewImage.sprite  = null;
 }
 /// <summary>
 /// 复制坦克部件管理器
 /// </summary>
 /// <param name="copySrc">复制源</param>
 public void CopyFrom(TankAssembleManager copySrc)
 {
     head        = copySrc.head;
     body        = copySrc.body;
     leftWheel   = copySrc.leftWheel;
     cap         = copySrc.cap;
     face        = copySrc.face;
     bodyForward = copySrc.bodyForward;
     bodyBack    = copySrc.bodyBack;
 }
 public void Clear()
 {
     head        = null;
     body        = null;
     leftWheel   = null;
     cap         = null;
     face        = null;
     bodyForward = null;
     bodyBack    = null;
 }
Example #5
0
 /// <summary>
 /// 通过头部获取子弹部件
 /// </summary>
 /// <param name="head">头部部件</param>
 /// <returns>返回对应的子弹部件</returns>
 public AmmoModule GetAmmo(TankModuleHead head)
 {
     for (int i = 0; i < headAmmoList.Count; i++)
     {
         if (headAmmoList[i].head == head)
         {
             return(headAmmoList[i].ammo);
         }
     }
     return(null);
 }
 /// <summary>
 /// 设置目标
 /// </summary>
 /// <param name="target">目标部件</param>
 public override void SetTarget(ModuleBase target)
 {
     this.target      = target;
     targetHeadModule = target as TankModuleHead;
     if (targetHeadModule == null)
     {
         return;
     }
     targetAmmoModule = headAmmoMap.GetAmmo(targetHeadModule);
     if (!targetAmmoModule)
     {
         Clean();
         return;
     }
     previewImage.sprite  = targetAmmoModule.preview;
     previewImage.enabled = true;
 }
Example #7
0
    public override Vector3 GetTargetAnchor(TankModule module)
    {
        TankModuleHead head = module as TankModuleHead;

        if (head == null)
        {
            Debug.LogError("TankModuleFace.GetTargetAnchor() Parameter Should Be 'TankModuleHead'.");
            return(Vector3.zero);
        }
        switch (targetPos)
        {
        case TargetPos.HeadForwardUp:
            return(head.forwardUp);

        case TargetPos.HeadForward:
            return(head.anchors.forward);
        }
        return(Vector3.zero);
    }
Example #8
0
 /// <summary>
 /// 连接头到身体
 /// </summary>
 /// <param name="head">头部件</param>
 /// <param name="headObj">头部件对象</param>
 /// <param name="body">身体部件</param>
 /// <param name="bodyObj">身体部件对象</param>
 static public void ConnectHeadToBody(TankModuleHead head, GameObject headObj, TankModuleBody body, GameObject bodyObj)
 {
     headObj.transform.position = bodyObj.transform.position + body.anchors.up - head.anchors.down;
 }