Exemplo n.º 1
0
        protected float DrawUnitOffensiveStats(float startX, float startY, Unit unit, bool isTower = true)
        {
            //EditorGUI.LabelField(new Rect(startX, startY, width, height), "Offensive Setting", headerStyle);
            string text = "Offensive Setting " + (!foldOffensive ? "(show)" : "(hide)");

            foldOffensive = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldOffensive, text, foldoutStyle);
            if (foldOffensive)
            {
                startX += 15;

                int objID;

                UnitTower tower = isTower ? unit.gameObject.GetComponent <UnitTower>() : null;
                UnitCreep creep = !isTower?unit.gameObject.GetComponent <UnitCreep>() : null;

                //add stop to attack for creep
                if (!isTower)
                {
                    cont = new GUIContent("Stop To Attack:", "Check to have the creep stop moving when there's target to attack");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    creep.stopToAttack = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), creep.stopToAttack);
                }

                //add target mode for tower
                if (isTower)
                {
                    int targetMode = (int)tower.targetMode;
                    cont = new GUIContent("Target Mode:", "Determine which type of unit the tower can target");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    contL = new GUIContent[targetModeLabel.Length];
                    for (int i = 0; i < contL.Length; i++)
                    {
                        contL[i] = new GUIContent(targetModeLabel[i], targetModeTooltip[i]);
                    }
                    targetMode       = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), targetMode, contL);
                    tower.targetMode = (_TargetMode)targetMode;
                }

                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 += spaceY, width, height), cont);
                unit.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.damageType, damageTypeLabel);

                startY += 8;

                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, widthS, 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++)
                    {
                        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;
                    }
                }

                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);
                if (unit.shootPoints.Count > 1)
                {
                    unit.delayBetweenShootPoint = EditorGUI.FloatField(new Rect(startX + spaceX + 90, startY - 1, widthS, height - 1), unit.delayBetweenShootPoint);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX + 90, startY - 1, widthS, height - 1), new GUIContent("-", ""));
                }

                startY += 8;

                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;

                startY += 8;

                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, widthS, height), unit.rotateTurretAimInXAxis);

                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, widthS, height), unit.directionalTargeting);

                cont = new GUIContent("- FOV:", "Field-Of-View of the directional targeting");
                EditorGUI.LabelField(new Rect(startX + spaceX + 60, startY, width, height), cont);
                if (unit.directionalTargeting)
                {
                    unit.dirScanFOV = EditorGUI.FloatField(new Rect(startX + spaceX + 110, startY, widthS, height), unit.dirScanFOV);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX + 110, startY, widthS, height), "-");
                }

                if (isTower)
                {
                    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 + spaceX + 60, startY += spaceY, width, height), cont);
                    if (unit.directionalTargeting)
                    {
                        unit.dirScanAngle = EditorGUI.FloatField(new Rect(startX + spaceX + 110, startY, widthS, height), unit.dirScanAngle);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX + 110, startY, widthS, height), "-");
                    }
                }

                //add weapon type for tower
                if (isTower)
                {
                    cont = new GUIContent("Disable FPS:", "Check to disable fps mode for this particular tower");
                    GUI.Label(new Rect(startX, startY += spaceY + 5, width, height), cont);
                    tower.disableFPS = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), tower.disableFPS);

                    cont = new GUIContent("FPS Weapon:", "Weapon tied to this tower when using FPS mode");
                    GUI.Label(new Rect(startX, startY += spaceY, width, height), cont);

                    if (!tower.disableFPS)
                    {
                        int weaponID = TDEditor.GetFPSWeaponIndex(tower.FPSWeaponID);
                        weaponID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponID, fpsWeaponLabel);
                        if (weaponID == 0)
                        {
                            tower.FPSWeaponID = -1;
                        }
                        else
                        {
                            tower.FPSWeaponID = fpsWeaponDB.weaponList[weaponID - 1].prefabID;
                        }
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                    }
                }
            }

            return(startY + spaceY);
        }