protected dfComponentMemberInfo EditPropertyInfo(dfComponentMemberInfo MemberInfo, Type DataType) { var sourceComponent = dfEditorUtil.ComponentField("Component", MemberInfo.Component); if (sourceComponent != MemberInfo.Component) { dfEditorUtil.MarkUndo(target, "Assign Data Source"); MemberInfo.Component = sourceComponent; } if (sourceComponent == null) { //EditorGUILayout.HelpBox( "Missing component", MessageType.Error ); return(MemberInfo); } var sourceComponentMembers = getMemberList(sourceComponent) .Where(m => isValidFieldType(m, DataType)) .Select(m => m.Name) .ToArray(); var memberIndex = findIndex(sourceComponentMembers, MemberInfo.MemberName); var selectedIndex = EditorGUILayout.Popup("Property", memberIndex, sourceComponentMembers); if (selectedIndex >= 0 && selectedIndex < sourceComponentMembers.Length) { var memberName = sourceComponentMembers[selectedIndex]; if (memberName != MemberInfo.MemberName) { dfEditorUtil.MarkUndo(target, "Assign Data Source"); MemberInfo.MemberName = memberName; } } return(MemberInfo); }
protected dfComponentMemberInfo EditPropertyInfo( dfComponentMemberInfo MemberInfo, Type DataType ) { var sourceComponent = dfEditorUtil.ComponentField( "Component", MemberInfo.Component ); if( sourceComponent != MemberInfo.Component ) { dfEditorUtil.MarkUndo( target, "Assign Data Source" ); MemberInfo.Component = sourceComponent; } if( sourceComponent == null ) { //EditorGUILayout.HelpBox( "Missing component", MessageType.Error ); return MemberInfo; } var sourceComponentMembers = getMemberList( sourceComponent ) .Where( m => isValidFieldType( m, DataType ) ) .Select( m => m.Name ) .ToArray(); var memberIndex = findIndex( sourceComponentMembers, MemberInfo.MemberName ); var selectedIndex = EditorGUILayout.Popup( "Property", memberIndex, sourceComponentMembers ); if( selectedIndex >= 0 && selectedIndex < sourceComponentMembers.Length ) { var memberName = sourceComponentMembers[ selectedIndex ]; if( memberName != MemberInfo.MemberName ) { dfEditorUtil.MarkUndo( target, "Assign Data Source" ); MemberInfo.MemberName = memberName; } } return MemberInfo; }
public void Stats() { Player Player = ParseUser.CurrentUser as Player; PhotonView[] players = GameObject.FindObjectsOfType <PhotonView>(); GameObject other = null; GameObject mine = null; // print("Number of PhotonViews: " + players.Length); foreach (PhotonView ph in players) { if (!ph.gameObject.name.Contains("HammerRobot")) { continue; } // print("ViewID: " + ph.viewID + ", SubID: " + ph.subId + ", InstantiationId: " + ph.instantiationId + ", Name: " + ph.name); if (!ph.isMine) { other = ph.gameObject; // print("Is not mine"); } else { // print("Is Mine"); mine = ph.gameObject; } } if (other != null) { //RobotController rc = mine.GetComponent<RobotController>(); //Destroy(rc); // rc.HumanActivate(other); //mine.AddComponent<BattleController>(); // var brain1 = Utility.LoadBrain(Application.persistentDataPath + string.Format("/Populations/{0}Champ.gnm.xml", "Mortar Precision")); var controller1 = mine.GetComponent <FightController>(); // controller1.HitLayers = 1 << LayerMask.NameToLayer("BattleRobot"); int activeNumber = -1; IBlackBox brain1 = null, brain2 = null, brain3 = null, brain4 = null, activeBrain = null; string path = ""; if (Player.Brain1 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain1.ObjectId); // print("Path: " + path); brain1 = Utility.LoadBrain(path); activeBrain = brain1; activeNumber = 1; } if (Player.Brain2 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain2.ObjectId); brain2 = Utility.LoadBrain(path); if (activeBrain == null) { activeBrain = brain2; activeNumber = 2; } } if (Player.Brain3 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain3.ObjectId); brain3 = Utility.LoadBrain(path); if (activeBrain == null) { activeBrain = brain3; activeNumber = 3; } } if (Player.Brain4 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain4.ObjectId); brain4 = Utility.LoadBrain(path); if (activeBrain == null) { activeBrain = brain4; activeNumber = 4; } } // print("Joe 1"); controller1.Activate(activeBrain, other); controller1.SetBrains(brain1, brain2, brain3, brain4); // print("Joe 2"); var opponent = other.GetComponent <FightController>(); gui.ResetTimer(); gui.MyRobot = controller1; gui.OpponentRobot = opponent; opponent.Opponent = controller1; // controller1.Opponent.Opponent = controller1; // controller1.Opponent.target = controller1.gameObject; gui.ResetButton.Controller = controller1.gameObject; // print("Joe 3"); GameObject UIRoot = GameObject.Find("Battle GUI"); // UIRoot.GetComponent<MouseTotem>().SetController(controller1); HealthScript health = mine.GetComponent <HealthScript>(); health.Died += new HealthScript.DeathEventHandler(health_Died); GameObject HealthBar = Instantiate(Resources.Load("HealthBar")) as GameObject; dfFollowObject Follow = HealthBar.GetComponent <dfFollowObject>(); Follow.attach = mine; HealthBar.transform.parent = UIRoot.transform; Follow.enabled = true; health.FollowScript = Follow; dfPropertyBinding prop = HealthBar.GetComponent <dfPropertyBinding>(); dfComponentMemberInfo info = new dfComponentMemberInfo(); info.Component = health; info.MemberName = "HealthPercentage"; prop.DataSource = info; dfComponentMemberInfo targetInfo = new dfComponentMemberInfo(); targetInfo.Component = HealthBar.GetComponent <dfProgressBar>(); targetInfo.MemberName = "Value"; prop.DataTarget = targetInfo; prop.Unbind(); prop.Bind(); prop.enabled = true; // print("Joe 4"); HealthScript oppHealth = other.GetComponent <HealthScript>(); oppHealth.Died += new HealthScript.DeathEventHandler(oppHealth_Died); GameObject OppHealthBar = Instantiate(Resources.Load("OppHealthBar")) as GameObject; dfFollowObject OppFollow = OppHealthBar.GetComponent <dfFollowObject>(); OppFollow.attach = other; OppHealthBar.transform.parent = UIRoot.transform; OppFollow.enabled = true; // OppHealthBar.transform.Find("Me Label").GetComponent<dfLabel>().Hide(); oppHealth.FollowScript = OppFollow; dfPropertyBinding oppProp = OppHealthBar.GetComponent <dfPropertyBinding>(); dfComponentMemberInfo oppInfo = new dfComponentMemberInfo(); oppInfo.Component = oppHealth; oppInfo.MemberName = "HealthPercentage"; oppProp.DataSource = oppInfo; dfComponentMemberInfo oppTargetInfo = new dfComponentMemberInfo(); oppTargetInfo.Component = OppHealthBar.GetComponent <dfProgressBar>(); oppTargetInfo.MemberName = "Value"; oppProp.DataTarget = oppTargetInfo; oppProp.Unbind(); oppProp.Bind(); oppProp.enabled = true; // print("Joe 5"); if (photonView.isMine) { // print("Setting color of other"); other.transform.Find("Body").renderer.material = ownColor; } else { // print("Not mine, Setting color of other"); other.transform.Find("Body").renderer.material = ownColor; // mine.transform.Find("Body").renderer.material = ownColor; } // print("Joe 6"); // GameLogger.Instance.StartLogging(controller1, controller1.Opponent); logger = new EventLogger(controller1, Application.loadedLevelName, currentFrame); logger.StartLogging(); gui.SetSelectedBrain(activeNumber); } }
public void Stats() { Player Player = ParseUser.CurrentUser as Player; PhotonView[] players = GameObject.FindObjectsOfType <PhotonView>(); GameObject other = null; GameObject mine = null; print("Number of PhotonViews: " + players.Length); foreach (PhotonView ph in players) { if (!ph.gameObject.name.Contains("ModRobot")) { continue; } print("ViewID: " + ph.viewID + ", SubID: " + ph.subId + ", InstantiationId: " + ph.instantiationId + ", Name: " + ph.name); if (!ph.isMine) { other = ph.gameObject; print("Is not mine"); } else { print("Is Mine"); mine = ph.gameObject; } } if (other != null) { //RobotController rc = mine.GetComponent<RobotController>(); //Destroy(rc); // rc.HumanActivate(other); //mine.AddComponent<BattleController>(); // var brain1 = Utility.LoadBrain(Application.persistentDataPath + string.Format("/Populations/{0}Champ.gnm.xml", "Mortar Precision")); var controller1 = mine.GetComponent <BattleController>(); controller1.HitLayers = 1 << LayerMask.NameToLayer("BattleRobot"); IBlackBox brain1 = null, brain2 = null, brain3 = null, brain4 = null, activeBrain = null; string path = ""; if (Player.Brain1 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain1.ObjectId); print("Path: " + path); brain1 = Utility.LoadBrain(path); activeBrain = brain1; } if (Player.Brain2 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain2.ObjectId); brain2 = Utility.LoadBrain(path); if (activeBrain == null) { activeBrain = brain2; } } if (Player.Brain3 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain3.ObjectId); brain3 = Utility.LoadBrain(path); if (activeBrain == null) { activeBrain = brain3; } } if (Player.Brain4 != null) { path = Application.persistentDataPath + string.Format("/{0}/{1}.champ.xml", Player.Username, Player.Brain4.ObjectId); brain4 = Utility.LoadBrain(path); if (activeBrain == null) { activeBrain = brain4; } } controller1.Activate(activeBrain, other); controller1.SetBrains(brain1, brain2, brain3, brain4); // gui.MyRobot = controller1; // gui.OpponentRobot = controller1.Opponent; GameObject UIRoot = GameObject.Find("UI Root"); HealthScript health = mine.GetComponent <HealthScript>(); GameObject HealthBar = Instantiate(Resources.Load("HealthBar")) as GameObject; dfFollowObject Follow = HealthBar.GetComponent <dfFollowObject>(); Follow.attach = mine; HealthBar.transform.parent = UIRoot.transform; Follow.enabled = true; health.FollowScript = Follow; dfPropertyBinding prop = HealthBar.GetComponent <dfPropertyBinding>(); dfComponentMemberInfo info = new dfComponentMemberInfo(); info.Component = health; info.MemberName = "Health"; prop.DataSource = info; dfComponentMemberInfo targetInfo = new dfComponentMemberInfo(); targetInfo.Component = HealthBar.GetComponent <dfProgressBar>(); targetInfo.MemberName = "Value"; prop.DataTarget = targetInfo; prop.Unbind(); prop.Bind(); prop.enabled = true; HealthScript oppHealth = other.GetComponent <HealthScript>(); GameObject OppHealthBar = Instantiate(Resources.Load("HealthBar")) as GameObject; dfFollowObject OppFollow = OppHealthBar.GetComponent <dfFollowObject>(); OppFollow.attach = other; OppHealthBar.transform.parent = UIRoot.transform; OppFollow.enabled = true; OppHealthBar.transform.Find("Me Label").GetComponent <dfLabel>().Hide(); oppHealth.FollowScript = OppFollow; dfPropertyBinding oppProp = OppHealthBar.GetComponent <dfPropertyBinding>(); dfComponentMemberInfo oppInfo = new dfComponentMemberInfo(); oppInfo.Component = oppHealth; oppInfo.MemberName = "Health"; oppProp.DataSource = oppInfo; dfComponentMemberInfo oppTargetInfo = new dfComponentMemberInfo(); oppTargetInfo.Component = OppHealthBar.GetComponent <dfProgressBar>(); oppTargetInfo.MemberName = "Value"; oppProp.DataTarget = oppTargetInfo; oppProp.Unbind(); oppProp.Bind(); oppProp.enabled = true; if (PhotonNetwork.isMasterClient) { mine.transform.Find("Body").renderer.material = ownColor; } else { other.transform.Find("Body").renderer.material = ownColor; } } }