コード例 #1
0
    /// <summary>
    /// Select the specified component - shows the effect and updates GUI to reflect potential power cost
    /// </summary>
    /// <param name="component"></param>
    /// <param name="select"></param>
    private void SelectComponent(ShipComponent component, bool select)
    {
        if (select)
        {
            if (!selectedComponents.Contains(component))
            {
                //Debug.Log("select");
                if(selectedComponents.Count>0)
                {
                    //not the same component type as selected - restart selection
                    if(component.GetType() != selectedComponents[0].GetType())
                    {
                        UnSelectComponents(true);
                    }
                }
                if (CurrentPower - totalActivationCost - component.ActivationCost < 0)
                {
                    #if FULL_DEBUG
                    Debug.LogWarning("Not enough power");
                    #endif
                    combatInterface.SetPowerValid(false);
                    return;
                }
                selectedComponents.Add(component);
                component.Selected = true;
                TutorialSystem.Instance.ShowNextTutorial(TutorialSystem.TutorialType.ComponentSelection);
                if (!allowingEnemyTargeting) AllowEnemyTargeting(true);
                totalActivationCost += component.ActivationCost;
                combatInterface.UpdateStats(CurrentPower - totalActivationCost, MoveCost,true);

            }//selected component contains
        }
        else //de-select
        {
            if(selectedComponents.Contains(component))
            {
                selectedComponents.Remove(component);
                component.Selected = false;
                if(selectedComponents.Count==0)
                {
                    AllowEnemyTargeting(false);
                }
                totalActivationCost -= component.ActivationCost;
                combatInterface.UpdateStats(CurrentPower - totalActivationCost, MoveCost,true);
            }
        }
    }
コード例 #2
0
 private void SelectComponent(ShipComponent component, bool select)
 {
     if (select)
     {
         //selected comp is not the same component type as selected - restart selection
         if (selectedComponents.Count > 0 && component.GetType() != selectedComponents[0].GetType())
         {
             UnSelectComponents();
         }
         //not enough power - return without selecting
         if ((CurrentPower - totalActivationCost - component.ActivationCost) < 0)
         {
     #if FULL_DEBUG
             Debug.LogWarning("Not enough power");
     #endif
             combatInterface.SetPowerValid(false);
             return;
         }
         //checks passed - select comp
         selectedComponents.Add(component);
         //tutorial next comp selection
         if (!allowingEnemyTargeting) AllowEnemyTargeting(true); ;
         totalActivationCost += component.ActivationCost;
     }//Select true
     else
     {
     #if FULL_DEBUG
         if (!selectedComponents.Contains(component))
         {
             Debug.LogError("Selected components doesn't contain " + component.componentName);
         }
     #endif
         selectedComponents.Remove(component);
         if (selectedComponents.Count == 0) AllowEnemyTargeting(false);
         totalActivationCost -= component.ActivationCost;
     }
     component.Selected = select;
     combatInterface.UpdateStats(CurrentPower - totalActivationCost, MoveCost, true);
 }