Ejemplo n.º 1
0
    public void AttachElectric(CSElectric cs)
    {
        if (m_Electrics.Exists(item0 => item0 == cs))
        {
            return;
        }

        if (m_IsRunning && InRange(cs.Position) &&
            m_RestPower >= cs.m_Power)
        {
            m_RestPower -= cs.m_Power;
            m_Electrics.Add(cs);
            cs.m_PowerPlant = this;
            cs.ChangeState();
        }
    }
Ejemplo n.º 2
0
    public void DetachCommonEntity(CSCommon csc)
    {
        csc.Assembly = null;
        //		m_BelongObjectsMap[(CSConst.ObjectType) csc.m_Type].Remove(csc);
        RemoveBelongBuilding((CSConst.ObjectType)csc.m_Type, csc);

        CSElectric cse = csc as CSElectric;

        if (cse != null)
        {
            if (cse.m_PowerPlant != null)
            {
                cse.m_PowerPlant.DetachElectric(cse);
            }
        }
        csc.ChangeState();
    }
Ejemplo n.º 3
0
    public int AttachCommonEntity(CSCommon csc)
    {
        if (csc.Assembly == this)
        {
            return(CSConst.rrtUnkown);
        }

        if (!InRange(csc.Position))
        {
            return(CSConst.rrtOutOfRadius);
        }

        CSConst.ObjectType type = (CSConst.ObjectType)csc.m_Type;
        if (IsOutOfLimit(type))
        {
            return(CSConst.rrtOutOfRange);
        }

        //		m_BelongObjectsMap[(CSConst.ObjectType) csc.m_Type].Add(csc);
        AddBelongBuilding((CSConst.ObjectType)csc.m_Type, csc);
        csc.Assembly = this;

        CSElectric cse = csc as CSElectric;

        if (cse != null)
        {
            foreach (CSCommon power in AllPowerPlants)
            {
                CSPowerPlant cspp = power as CSPowerPlant;
                cspp.AttachElectric(cse);
                if (cse.IsRunning)
                {
                    break;
                }
            }
        }

        csc.ChangeState();

        return(CSConst.rrtSucceed);
    }
Ejemplo n.º 4
0
    CSUI_BuildingIcon _createIcons(CSElectric cse)
    {
        CSUI_BuildingIcon bi = Instantiate(m_Supply.m_IconPrefab) as CSUI_BuildingIcon;

        bi.transform.parent        = m_Supply.m_Root.transform;
        bi.transform.localPosition = Vector3.zero;
        bi.transform.localRotation = Quaternion.identity;
        bi.transform.localScale    = Vector3.one;

        string[] iconStr = ItemProto.GetIconName(cse.ItemID);
        if (iconStr.Length != 0)
        {
            bi.IconName = iconStr[0];
        }
        else
        {
            bi.IconName = "";
        }
        bi.Description = cse.Name;

        m_Icons.Add(bi);

        return(bi);
    }
Ejemplo n.º 5
0
    protected void FindElectrics()
    {
        foreach (KeyValuePair <CSConst.ObjectType, List <CSCommon> > kvp in Assembly.m_BelongObjectsMap)
        {
            if (CSAssembly.IsPowerPlant(kvp.Key))
            {
                continue;
            }

            foreach (CSCommon tempCsc in kvp.Value)
            {
                CSElectric cse = tempCsc as CSElectric;
                if (cse == null)
                {
                    break;
                }

                if (!cse.IsRunning)
                {
                    AttachElectric(cse);
                }
            }
        }
    }
Ejemplo n.º 6
0
 public void AddElectric(CSElectric csel)
 {
     m_RestPower -= csel.m_Power;
     m_Electrics.Add(csel);
 }
Ejemplo n.º 7
0
 public void RemoveElectric(CSElectric csel)
 {
     m_RestPower += csel.m_Power;
     m_Electrics.Remove(csel);
 }
Ejemplo n.º 8
0
 public void DetachElectric(CSElectric cs)
 {
     m_Electrics.Remove(cs);
     cs.m_PowerPlant = null;
     cs.ChangeState();
 }