예제 #1
0
        public static Vector3 DrawUnitOffensiveSetting(UnitTower tower, UnitCreep creep, float startX, float startY, List <GameObject> objHList, string[] objHLabelList)
        {
            float cachedX = startX;

            Unit unit = null;

            if (tower != null)
            {
                unit = tower;
            }
            if (creep != null)
            {
                unit = creep;
            }



            if (tower && TowerDealDamage(tower) || (creep && creep.type == _CreepType.Offense))
            {
                string[] damageTypeLabel = EditorDBManager.GetDamageTypeLabel();
                cont = new GUIContent("Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                unit.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.damageType, damageTypeLabel);
            }

            if (tower && TowerUseShootObject(tower) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
                shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                int shootPointCount = unit.shootPoints.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

                if (shootPointCount != unit.shootPoints.Count)
                {
                    while (unit.shootPoints.Count < shootPointCount)
                    {
                        unit.shootPoints.Add(null);
                    }
                    while (unit.shootPoints.Count > shootPointCount)
                    {
                        unit.shootPoints.RemoveAt(unit.shootPoints.Count - 1);
                    }
                }

                if (shootPointFoldout)
                {
                    for (int i = 0; i < unit.shootPoints.Count; i++)
                    {
                        int objID = GetObjectIDFromHList(unit.shootPoints[i], objHList);
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                        objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                        unit.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                    }
                }

                if (unit.shootPoints.Count > 1)
                {
                    cont = new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 60, height), cont);
                    unit.delayBetweenShootPoint = EditorGUI.FloatField(new Rect(startX + spaceX + 90, startY - 1, 55, height - 1), unit.delayBetweenShootPoint);
                }
            }


            if (tower && TowerUseTurret(tower) || (creep && creep.type == _CreepType.Offense))
            {
                int objID = GetObjectIDFromHList(unit.turretObject, objHList);
                cont = new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.turretObject = (objHList[objID] == null) ? null : objHList[objID].transform;
            }

            return(new Vector3(cachedX, startY, spaceX + width));
        }
예제 #2
0
        public static Vector3 DrawUnitOffensiveSetting(UnitTower tower, UnitCreep creep, float startX, float startY, List <GameObject> objHList, string[] objHLabelList)
        {
            float cachedX = startX;
            //float cachedY=startY;

            Unit unit = null;

            if (tower != null)
            {
                unit = tower;
            }
            if (creep != null)
            {
                unit = creep;
            }



            if (tower && TowerDealDamage(tower) || (creep && creep.type == _CreepType.Offense))
            {
                string[] damageTypeLabel = EditorDBManager.GetDamageTypeLabel();
                cont = new GUIContent("Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                unit.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.damageType, damageTypeLabel);
            }

            if (tower && TowerUseShootObject(tower) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
                shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                int shootPointCount = unit.shootPoints.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

                if (shootPointCount != unit.shootPoints.Count)
                {
                    while (unit.shootPoints.Count < shootPointCount)
                    {
                        unit.shootPoints.Add(null);
                    }
                    while (unit.shootPoints.Count > shootPointCount)
                    {
                        unit.shootPoints.RemoveAt(unit.shootPoints.Count - 1);
                    }
                }

                if (shootPointFoldout)
                {
                    for (int i = 0; i < unit.shootPoints.Count; i++)
                    {
                        int objID = GetObjectIDFromHList(unit.shootPoints[i], objHList);
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                        objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                        unit.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                    }
                }

                if (unit.shootPoints.Count > 1)
                {
                    cont = new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 60, height), cont);
                    unit.delayBetweenShootPoint = EditorGUI.FloatField(new Rect(startX + spaceX + 90, startY - 1, 55, height - 1), unit.delayBetweenShootPoint);
                }
            }


            if (tower && TowerUseTurret(tower) || (creep && creep.type == _CreepType.Offense))
            {
                int objID = GetObjectIDFromHList(unit.turretObject, objHList);
                cont = new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.turretObject = (objHList[objID] == null) ? null : objHList[objID].transform;

                objID = GetObjectIDFromHList(unit.barrelObject, objHList);
                cont  = new GUIContent("BarrelObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). This is only required if the unit barrel and turret rotates independently on different axis");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.barrelObject = (objHList[objID] == null) ? null : objHList[objID].transform;

                cont = new GUIContent("Aim Rotate In x-axis:", "Check if the unit turret/barrel can rotate in x-axis (elevation)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.rotateTurretAimInXAxis = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, 40, height), unit.rotateTurretAimInXAxis);
            }


            if (tower && TowerTargetHostile(tower) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("Directional Targeting:", "Check if the unit should only target hostile unit from a fixed direction");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.directionalTargeting = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, 40, height), unit.directionalTargeting);

                if (unit.directionalTargeting)
                {
                    startX += spaceX + 50;

                    cont = new GUIContent("- FOV:", "Field-Of-View of the directional targeting");
                    EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                    unit.dirScanFOV = EditorGUI.FloatField(new Rect(startX + 60, startY, 40, height), unit.dirScanFOV);

                    if (tower != null)
                    {
                        cont = new GUIContent("- Angle:", "The y-axis angle in clock-wise (from transform local space) which the directional targeting will be aim towards\n0: +ve z-axis\n90: +ve x-axis\n180: -ve z-axis\n270: -ve x-axis");
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                        unit.dirScanAngle = EditorGUI.FloatField(new Rect(startX + 60, startY, 40, height), unit.dirScanAngle);
                    }
                }
            }

            return(new Vector3(cachedX, startY, spaceX + width));
        }