// 更新 GUIText的顏色 private void UpdateGUIText( GameObject _GUIComponent , string _ChildName , UnitComponentData _ComponentData ) { if( null == _GUIComponent || null == _ComponentData ) return ; Color LabelColor = ComponentStatusColor.GetColor( _ComponentData.componentStatus ) ; Transform trans = _GUIComponent.transform.FindChild( _ChildName ) ; if( null != trans ) { GameObject obj = trans.gameObject ; GUIText guiText = obj.GetComponent<GUIText>() ; if( null != guiText ) { guiText.material.color = LabelColor ; } } }
public UnitComponentData( UnitComponentData _src ) { this.m_Name = _src.m_Name ; this.m_HP = new StandardParameter( _src.m_HP ) ; this.m_Energy = new StandardParameter( _src.m_Energy ) ; this.m_Generation = new StandardParameter( _src.m_Generation ) ; this.m_Effect = new StandardParameter( _src.m_Effect ) ; this.m_Status = _src.m_Status ; this.m_StatusDescription = new StatusDescription( _src.m_StatusDescription ) ; this.m_Effect_HP_Curve = new InterpolateTable( _src.m_Effect_HP_Curve ) ; this.m_ReloadEnergy = new StandardParameter( _src.m_ReloadEnergy ) ; this.m_ReloadGeneration = new StandardParameter( _src.m_ReloadGeneration ) ; this.m_WeaponReloadStatus = _src.m_WeaponReloadStatus ; this.m_ComponentParam = new ComponentParam( _src.m_ComponentParam ) ; this.m_WeaponParam = new WeaponParam( _src.m_WeaponParam ) ; }
/* * 更新一個部件的各個UnitDataGUI物件 * 呼叫 UpdateGUIComponentObject() 更新HP * 呼叫 UpdateGUIComponentObject() 更新Reload * 呼叫 UpdateGUIText() 更新 Label */ private void UpdateAllGUIObjsOfGUIComponent( UnitComponentData _ComponentData , GameObject _GUIComponent ) { if( null == _GUIComponent || null == _ComponentData ) return ; // try find HP UpdateGUIComponentObject( _GUIComponent , ConstName.UnitDataGUIComponentHP , _ComponentData.m_HP.Ratio() ) ; // try find Reload UpdateGUIComponentObject( _GUIComponent , ConstName.UnitDataGUIComponentReload , _ComponentData.m_ReloadEnergy.Ratio() ) ; // try find Label UpdateGUIText( _GUIComponent , ConstName.UnitDataGUIComponentLabel , _ComponentData ) ; }
private bool WeaponReloadIsReady( UnitComponentData _WeaponComponent ) { return ( _WeaponComponent.m_WeaponReloadStatus == WeaponReloadStatus.WeaponReloadStatus_Full ) ; }
/* * @brief Parse component from xml */ private bool ParseComponent( XmlNode _ComponentNode , out UnitComponentData _Component ) { _Component = new UnitComponentData() ; if( null == _ComponentNode ) return false ; if( null == _ComponentNode.Attributes[ "name" ] ) return false ; string name = _ComponentNode.Attributes[ "name" ].Value ; if( 0 == name.Length ) return false ; // assign component parameter from table componentParamTable[]. if( true == this.componentParamTable.ContainsKey( name ) ) { _Component.m_ComponentParam = new ComponentParam( this.componentParamTable[ name ] ) ; } // assign weapon parameter from table weaponParamTable[]. if( true == this.weaponParamTable.ContainsKey( name ) ) { _Component.m_WeaponParam = new WeaponParam( this.weaponParamTable[ name ] ) ; } _Component.m_Name = name ; for( int i = 0 ; i < _ComponentNode.ChildNodes.Count ; ++i ) { string label ; StandardParameter newStandardParameter ; XMLParseLevelUtility.ParseStandardParameter( _ComponentNode.ChildNodes[ i ] , out label , out newStandardParameter ) ; /* public StandardParameter m_HP = new StandardParameter() ; public StandardParameter m_Generation = new StandardParameter() ; public StandardParameter m_Energy = new StandardParameter() ; public StandardParameter m_Effect = new StandardParameter() ; public ComponentStatus m_Status = ComponentStatus.ComponentStatus_Normal ; public StatusDescription m_StatusDescription = new StatusDescription() ; public InterpolateTable m_Effect_HP_Curve = new InterpolateTable() ; // weapon only public StandardParameter m_ReloadEnergy = new StandardParameter() ; public StandardParameter m_ReloadGeneration = new StandardParameter() ; public WeaponStatus m_WeaponStatus ; */ if( "hp" == label ) { _Component.m_HP = new StandardParameter( newStandardParameter ) ; } else if( "energy" == label ) { _Component.m_Energy = new StandardParameter( newStandardParameter ) ; } else if( "generation" == label ) { _Component.m_Generation = new StandardParameter( newStandardParameter ) ; } else if( "effect" == label ) { _Component.m_Effect = new StandardParameter( newStandardParameter ) ; } else if( "reloadEnergy" == label ) { _Component.m_ReloadEnergy = new StandardParameter( newStandardParameter ) ; } else if( "reloadGeneration" == label ) { _Component.m_ReloadGeneration = new StandardParameter( newStandardParameter ) ; } } return ( 0 != _Component.m_Name.Length ) ; }
public void SendReloadCompletenessMessage( UnitComponentData _componentData ) { if( null == _componentData ) return ; ReloadAnimationManager animator = GlobalSingleton.GetReloadAnimationManager() ; if( null == animator ) return ; animator.Setup( this.gameObject.name , _componentData.m_Name ) ; }
public void AssignComponent( string _Key , UnitComponentData _component ) { componentMap[ _Key ] = new UnitComponentData( _component ) ; }