public override Vector3 GetTargetAnchor(TankModule module)
    {
        TankModuleBody body = module as TankModuleBody;

        if (body == null)
        {
            Debug.LogError("TankModuleBodyForward.GetTargetAnchor() Parameter Should Be 'TankModuleBody'.");
            return(Vector3.zero);
        }
        switch (targetPos)
        {
        case TargetPos.BodyForwardUp:
            return(body.forwardUp);

        case TargetPos.BodyForward:
            return(body.anchors.forward);
        }
        return(Vector3.zero);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 获取文件目录下所有坦克部件
    /// </summary>
    private void GetModuleList()
    {
        if (!Directory.Exists(fullPath))
        {
            Debug.LogError(fullPath + " Doesn't Exists");
            return;
        }

        FileInfo[] files = new DirectoryInfo(fullPath).GetFiles("*.asset", SearchOption.AllDirectories);

        for (int i = 0; i < files.Length; i++)
        {
            temModule = AssetDatabase.LoadAssetAtPath <TankModule>(string.Format("{0}{1}{2}{3}", "Assets", path, "/", files[i].Name));
            if (temModule != null)
            {
                moduleList.Add(temModule);
            }
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 连接组合所有部件
    /// </summary>
    public void AssembleTank()
    {
        TankModule.ConnectHeadToBody(head, headObj, body, bodyObj);
        TankModule.ConnectLeftWheelToBody(leftWheel, leftWheelObj, body, bodyObj);
        TankModule.ConnectRightWheelToBody(leftWheel, rightWheelObj, body, bodyObj);

        if (cap != null)
        {
            TankModule.ConnectDecorationModule(cap, capObj, head, headObj);
        }
        if (face != null)
        {
            TankModule.ConnectDecorationModule(face, faceObj, head, headObj);
        }
        if (bodyForward != null)
        {
            TankModule.ConnectDecorationModule(bodyForward, bodyForwardObj, body, bodyObj);
        }
        if (bodyBack != null)
        {
            TankModule.ConnectDecorationModule(bodyBack, bodyBackObj, body, bodyObj);
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// 获取部件类型枚举值
 /// </summary>
 /// <param name="module">目标部件</param>
 /// <returns>目标部件的类型枚举值</returns>
 static public TankModuleType GetModuleType(TankModule module)
 {
     if (module.GetType() == typeof(TankModuleHead))
     {
         return(TankModuleType.Head);
     }
     else if (module.GetType() == typeof(TankModuleBody))
     {
         return(TankModuleType.Body);
     }
     else if (module.GetType() == typeof(TankModuleWheel))
     {
         return(TankModuleType.Wheel);
     }
     else if (module.GetType() == typeof(TankModuleCap))
     {
         return(TankModuleType.Cap);
     }
     else if (module.GetType() == typeof(TankModuleFace))
     {
         return(TankModuleType.Face);
     }
     else if (module.GetType() == typeof(TankModuleBodyForward))
     {
         return(TankModuleType.BodyForward);
     }
     else if (module.GetType() == typeof(TankModuleBodyBack))
     {
         return(TankModuleType.BodyBack);
     }
     else if (module.GetType() == typeof(TankModule))
     {
         return(TankModuleType.Default);
     }
     return(TankModuleType.None);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 连接装饰部件
 /// </summary>
 /// <param name="decoration">装饰部件</param>
 /// <param name="decorationObj">装饰部件对象</param>
 /// <param name="targetModule">连接目标部件</param>
 /// <param name="targetObj">连接目标部件对象</param>
 static public void ConnectDecorationModule(TankModuleDecoration decoration, GameObject decorationObj, TankModule targetModule, GameObject targetObj)
 {
     decorationObj.transform.SetParent(targetObj.transform);
     decorationObj.transform.position = targetObj.transform.position + decoration.GetTargetAnchor(targetModule) - decoration.connectAnchor;
 }
Exemplo n.º 7
0
    /// <summary>
    /// 预览新的坦克部件
    /// </summary>
    /// <param name="modulePreview">目标部件</param>
    public void PreviewNewModule(TankModulePreviewManager modulePreview)
    {
        switch (TankModule.GetModuleType(modulePreview.target as TankModule))
        {
        case TankModule.TankModuleType.Head:
            if (modulePreview.target == TemporaryAssemble.head)
            {
                return;
            }
            else
            {
                TemporaryAssemble.head = modulePreview.target as TankModuleHead;
            }
            break;

        case TankModule.TankModuleType.Body:
            if (modulePreview.target == TemporaryAssemble.body)
            {
                return;
            }
            else
            {
                TemporaryAssemble.body = modulePreview.target as TankModuleBody;
            }
            break;

        case TankModule.TankModuleType.Wheel:
            if (modulePreview.target == TemporaryAssemble.leftWheel)
            {
                return;
            }
            else
            {
                TemporaryAssemble.leftWheel = modulePreview.target as TankModuleWheel;
            }
            break;

        //case TankModule.TankModuleType.Other:
        //    if (TemporaryAssemble.others.Contains(modulePreview.target as TankModuleOther))
        //        TemporaryAssemble.others.Remove(modulePreview.target as TankModuleOther);
        //    else
        //        TemporaryAssemble.others.Add(modulePreview.target as TankModuleOther);
        //    break;
        case TankModule.TankModuleType.Cap:
            TemporaryAssemble.cap = modulePreview.target == TemporaryAssemble.cap ? null : modulePreview.target as TankModuleCap;
            break;

        case TankModule.TankModuleType.Face:
            TemporaryAssemble.face = modulePreview.target == TemporaryAssemble.face ? null : modulePreview.target as TankModuleFace;
            break;

        case TankModule.TankModuleType.BodyForward:
            TemporaryAssemble.bodyForward = modulePreview.target == TemporaryAssemble.bodyForward ? null : modulePreview.target as TankModuleBodyForward;
            break;

        case TankModule.TankModuleType.BodyBack:
            TemporaryAssemble.bodyBack = modulePreview.target == TemporaryAssemble.bodyBack ? null : modulePreview.target as TankModuleBodyBack;
            break;

        default:
            return;
        }

        PreviewTemporaryTank();
    }
Exemplo n.º 8
0
 public abstract Vector3 GetTargetAnchor(TankModule module);