public override HResult Initialize() { try { var hr = base.Initialize(); if (ErrorUtil.Failure(hr)) { return(hr); } var commandManager = (INiCommandManager)GetService(typeof(INiCommandManager)); var menuManager = (NiMenuManager)GetService(typeof(INiMenuManager)); INiCommandBar toolbar; ErrorUtil.ThrowOnFailure(commandManager.FindCommandBar(_id, out toolbar)); if (toolbar != null) { _control = menuManager.CreateHost((NiCommandBar)toolbar); var toolStrip = (ToolStrip)_control.Control; toolStrip.GripStyle = ToolStripGripStyle.Hidden; Controls.Add(toolStrip); } return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
private void InsertToolBar(BarControl commandBar, ToolStrip toolStrip) { var toolStripPanel = _toolStripContainer.TopToolStripPanel; var toolStrips = toolStripPanel.Controls .Cast <ToolStrip>() .OrderBy(p => p.Top) .ThenBy(p => p.Left) .ToList(); if (toolStrips.Count > 0) { int rows = toolStripPanel.Rows.Length; toolStripPanel.Join( toolStrip, new Point( Math.Min(toolStrips[toolStrips.Count - 1].Right, toolStripPanel.Width), toolStrips[toolStrips.Count - 1].Top ) ); if (rows != toolStripPanel.Rows.Length) { toolStripPanel.Controls.Remove(toolStrip); toolStripPanel.Join(toolStrip, rows); } } else { toolStripPanel.Join(toolStrip); } }
// Update is called once per frame void Update() { if (pd) { img.enabled = true; barCon = GetComponentInChildren <BarControl>(); barCon.SetBar(pd.health); // get.sizeDelta *= 10.0f / Camera.main.fieldOfView; // get the new transform position Vector3 rawPos = viewCamera.WorldToScreenPoint(Player.transform.position); rawPos.y += heightOffset / viewCamera.fieldOfView; rawPos.x -= widthOffset / viewCamera.fieldOfView; transform.position = rawPos; GetComponent <RectTransform>().sizeDelta = rectOrigin * 10.0f / viewCamera.fieldOfView; // Debug.Log(pd.health); } else { // fetch the player by id, and get the player data img.enabled = false; Player = UserInfoManager.Instance.GetPlayerObjById(playerId); if (Player) { pd = Player.GetComponent <PlayerData> (); } } }
void Start() { almostOver = false; gameOver = false; deathTime = 3.0f; bar = GetComponent <BarControl>(); }
void Start() { debugLog = Camera.main.GetComponent <LogControl>(); Bar = gameObject.GetComponent <BarControl>(); ClearPlagues(); startTime = Random.Range(10.0f, 15.0f); duration = Random.Range(20.0f, 30.0f); }
internal void InsertCommandBar(BarControl commandBar) { if (commandBar.Bar.Kind == NiCommandBarKind.Menu) { InsertMenu(commandBar, (ToolStripMenuItem)commandBar.Control); } else { InsertToolBar(commandBar, (ToolStrip)commandBar.Control); } }
protected override void Dispose(bool disposing) { if (!_disposed) { if (_control != null) { _control.Dispose(); _control = null; } _disposed = true; } base.Dispose(disposing); }
// Use this for initialization void Start() { bar = GetComponent <BarControl>(); if (bar == null) { Debug.LogError("this object DOESN'T HAVE BarControl"); enabled = true; } float val; GameManager.Instance.GetParameter(parameterName, out val); bar.SetValueImmediately(val); }
public void DoMouseDown(MouseEventArgs e) { base.OnMouseDown(e); FMouseDownPt.X = e.X; FMouseDownPt.Y = e.Y; if (HC.PtInRect(FLeftBtnRect, FMouseDownPt)) { FMouseDownControl = BarControl.cbcLeftBtn; // 鼠标所在区域类型 ScrollStep(ScrollCode.scLineUp); // 数据向上(左)滚动 } else if (HC.PtInRect(FThumRect, FMouseDownPt)) { FMouseDownControl = BarControl.cbcThum; } else if (HC.PtInRect(FRightBtnRect, FMouseDownPt)) { FMouseDownControl = BarControl.cbcRightBtn; ScrollStep(ScrollCode.scLineDown); // 数据向下(右)滚动 } else // 鼠标在滚动条的其他区域 if (PtInLeftBlankArea(e.X, e.Y)) // 左空白区域 { } else if (PtInRightBlankArea(e.X, e.Y)) // 右空白区域 { } else { FMouseDownControl = BarControl.cbcBar; // 滚动条其他区域类型 if ((FThumRect.Top > e.Y) || (FThumRect.Left > e.X)) { ScrollStep(ScrollCode.scPageUp); // 数据向上(左)翻页 } else if ((FThumRect.Bottom < e.Y) || (FThumRect.Right < e.X)) { ScrollStep(ScrollCode.scPageDown); // 数据向下(右)翻页 } } }
private void InsertMenu(BarControl commandBar, ToolStripMenuItem menuItem) { if (menuItem == null) { throw new ArgumentNullException("menuItem"); } var items = _menuStrip.Items; int insertIndex = items.Count; for (int i = 0; i < items.Count; i++) { if (((BarControl)items[i].Tag).Bar.Priority > commandBar.Bar.Priority) { insertIndex = i; break; } } _menuStrip.Items.Insert(insertIndex, menuItem); }
public void reset() { currentHealth = maxHealth; currentHealth = maxHealth; if (healthBarGameObject != null) { GameObject bar = ObjectPool.instance.GetObjectForType(healthBarGameObject); if (bar != null) { FollowObject follow = bar.GetComponent <FollowObject>(); if (follow != null) { follow.setFollowing(this.gameObject); } healthBar = bar.GetComponent <BarControl>(); } } if (healthBar != null) { healthBar.setPercent(currentHealth, maxHealth); } }
// Use this for initialization void Start() { Bar = GameObject.Find("Main Camera").GetComponent <BarControl>(); }
void Update() { //Zostawiam to jako szkielet multitoucha - duuuuzzoooo obliczen /*if (Input.touchCount > 0) * { * touches = new GameObject[touchList.Count]; * touchList.CopyTo(touches); * touchList.Clear(); * foreach(GameObject touch in touches) * { * Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); * RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero); * } * }*/ if (Input.GetMouseButtonDown(0)) //mouse { Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero); if (hit.collider != null) //jezeli w cos trafimy { if (hit.collider.CompareTag("Pot")) { if (!charge) { charge = true; } else { power = true; } } } } /*else if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended && !once) * { * Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position); * RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero); * if (hit.collider != null) //jezeli w cos trafimy * { * if (hit.collider.CompareTag("Pot")) * { * if (!charge && !once) * { * charge = true; * debugLog.Set("Charged"); * } * else if(!once) * { * power = true; * debugLog.Set("Superpower bithes!"); * } * } * } * once = true; * } * if (once) * { * timeonce += Time.deltaTime; * if (timeonce > onceOff) * { * once = false; * timeonce = 0.0f; * } * } */ if (charge) { time += Time.deltaTime; if (time > turnOff) { charge = false; time = 0.0f; } } else if (power) { Debug.Log("Superumiejetnosc bitches"); BarControl bar = Camera.main.GetComponent <BarControl>(); bar.ClearBars(); power = false; } }
// ******************************************************************************************************** // OBJECTS CREATION *************************************************************************************** // ******************************************************************************************************** // CREATION OF NEW NORM POLE public GameObject CreateNormPole(int poleID, Vector3 startPoint, float startYRotation, BeltType[] beltTypes, PoleParams poleParams, PoleModification poleModif) { // CREATE THE NORM POLE GameObject newNormPole = Instantiate(poleNormPrefab, startPoint + new Vector3(0, 2.5f, 0), Quaternion.Euler(0, 0, 0)); PoleControl newNormPoleControl = newNormPole.GetComponent <PoleControl>(); Vector3 newNormPoleScale = newNormPole.transform.lossyScale; Vector3 newNormPoleScaleInv = new Vector3(1 / newNormPoleScale.x, 1 / newNormPoleScale.y, 1 / newNormPoleScale.z); Vector3 newNormPoleAIMoveDir = Quaternion.Euler(0, startYRotation, 0) * newNormPole.transform.forward; // TRANSFERRING GLOBAL OBJECTS, POLE PARAMS, MODIFICATION AND ASSEMBLY TO NEW POLE newNormPoleControl.globalObjects = globalObjects; newNormPoleControl.poleParams = poleParams; newNormPoleControl.poleModif = poleModif; newNormPoleControl.poleAssembly = newNormPole.transform.GetChild(0).gameObject; newNormPoleControl.AIMoveDir = newNormPoleAIMoveDir; // IF NEW POLE IS PLAYER - UPDATING GLOBAL PARAMS if (poleParams.type == PoleType.Player) { globalObjects.playerPole = newNormPole; playerPole = newNormPole; mainCamera.GetComponent <CameraControl>().focusObject = newNormPole; } // SENSOR CREATION GameObject newSensor = Instantiate(sensor1Prefab, startPoint + new Vector3(0, 4.5f, 0), newNormPole.transform.rotation, newNormPoleControl.poleAssembly.transform); newNormPoleControl.selfSensor = newSensor; newSensor.transform.localScale = newNormPoleScaleInv; // CREATING TEXT Text newText = Instantiate <Text>(infoText); newText.transform.SetParent(mainCanvas.transform); newText.transform.position = mainCanvas.transform.TransformPoint((poleID + 1) * 200 - Screen.width / 2 + 10, Screen.height / 2 - 10, 0); // CREATING ENERGYBAR Image newEnergyBar = Instantiate <Image>(globalObjects.barPrefab); newEnergyBar.transform.SetParent(mainCanvas.transform); BarControl newEnergyBarControl = newEnergyBar.GetComponent <BarControl>(); newEnergyBarControl.maxValue = poleParams.poleMaxEnergy * poleModif.energyMaxCoef; newEnergyBarControl.currValue = poleParams.poleMaxEnergy * poleModif.energyMaxCoef; newEnergyBarControl.transparency = poleParams.barTransparency; newEnergyBarControl.barHeight = barHeight; // DEFINING COLORS AND TAG switch (poleParams.type) { case PoleType.Player: newEnergyBarControl.backGroundCol = new Color32(0, 10, 73, newEnergyBarControl.transparency); newEnergyBarControl.foreGroundCol = new Color32(70, 100, 230, newEnergyBarControl.transparency); newText.color = new Color32(0, 230, 10, 255); newNormPole.tag = "PlayerTeam"; break; case PoleType.Enemy: newEnergyBarControl.backGroundCol = new Color32(0, 10, 73, newEnergyBarControl.transparency); newEnergyBarControl.foreGroundCol = new Color32(70, 100, 230, newEnergyBarControl.transparency); newText.color = new Color32(225, 0, 0, 255); newNormPole.tag = "EnemyTeam"; break; case PoleType.NeutralStatic: newText.color = new Color32(160, 160, 160, 255); newNormPole.tag = "NeutralTeam"; break; case PoleType.NeutralMovable: newText.color = new Color32(200, 200, 200, 255); newNormPole.tag = "NeutralTeam"; break; } // CREATING BELTS if (beltTypes.Length > 4) { Array.Resize(ref beltTypes, 4); } GameObject[] belts = new GameObject[beltTypes.Length]; if (beltTypes.Length > 0) { // INITIALIZING FIRST BELT PARAMS WITH UNIT PARAMS BeltParams[] newBeltsParams = new BeltParams[beltTypes.Length]; for (int i = 0; i < beltTypes.Length; i++) { // DEFINITION OF BELT SIDE if (UnitGroups.frontUnits.Contains(beltTypes[i])) { // FRONT-ORIENTED BELT newBeltsParams[i] = CreateBeltParams(beltTypes[i], BeltSide.front, poleID); } else if (UnitGroups.backUnits.Contains(beltTypes[i])) { // BACK-ORIENTED BELT newBeltsParams[i] = CreateBeltParams(beltTypes[i], BeltSide.back, poleID); } else { // SIDE-ORIENTED BELT if ((i == 0) || (!UnitGroups.sideUnits.Contains(beltTypes[i - 1]))) { // RANDOM SIDE DEFINITION if (UnityEngine.Random.Range(0, 100) < 50) { // BELT IS RANDOMLY LEFT newBeltsParams[i] = CreateBeltParams(beltTypes[i], BeltSide.left, poleID); } else { // BELT IS RANDOMLY RIGHT newBeltsParams[i] = CreateBeltParams(beltTypes[i], BeltSide.right, poleID); } } else { // DEFINING OTHER DIRECTION THEN IN PREVIOUS BELT if (newBeltsParams[i - 1].side == BeltSide.left) { newBeltsParams[i] = CreateBeltParams(beltTypes[i], BeltSide.right, poleID); } else { newBeltsParams[i] = CreateBeltParams(beltTypes[i], BeltSide.left, poleID); } } } // CREATING BELT OBJECT belts[i] = CreateBeltObject(poleID, newBeltsParams[i], ref poleModif, newNormPole, 0.55f - i * 0.1f); } } // TRANSFERRING BELTS, SENSOR, TEXT AND HEALTHBAR TO THE NEW POLE OBJECT if (beltTypes.Length > 0) { Array.Resize(ref newNormPoleControl.belts, belts.Length); Array.Resize(ref newNormPoleControl.beltTypes, beltTypes.Length); belts.CopyTo(newNormPoleControl.belts, 0); beltTypes.CopyTo(newNormPoleControl.beltTypes, 0); } newNormPoleControl.poleSensor = newSensor; newNormPoleControl.lifeText = newText; newNormPoleControl.energyBar = newEnergyBar; return(newNormPole); }
//private float[] orientAngles = { 90, 45, 22.5F, 0.1F, -1, -22.5F, -45, -90 }; // START void Start() { // ENERGY INIT energy = poleParams.poleMaxEnergy * poleModif.energyMaxCoef; energyBarControl = energyBar.GetComponent <BarControl>(); // SPEED INIT poleSpeed = new Vector3(0, 0, 0); // GETTING BELT CONTROLS Array.Resize(ref beltControls, belts.Length); for (int i = 0; i < beltControls.Length; i++) { beltControls[i] = belts[i].GetComponent <BeltControl>(); } // INFO INIT AIParams = new string[6]; AIParams[0] = "AIRandomMove: " + poleParams.AIRandomMove.ToString(); AIParams[1] = "AISearchingMove: " + poleParams.AISearchingMove.ToString(); AIParams[2] = "AIFiringOnContact: " + poleParams.AIFiringOnContact.ToString(); AIParams[3] = "AITargetMovePrediction: " + poleParams.AITargetMovePrediction.ToString(); AIParams[4] = "AIManuvering: " + poleParams.AIManuvering.ToString(); AIParams[5] = "AISeekLastPosition: " + poleParams.AISeekLastPosition.ToString(); // BEHAVIOR DELEGATE INIT switch (poleParams.type) { case PoleType.Player: Behave = new BehaviorDelegate(PlayerBehavior); break; case PoleType.Enemy: AIBehave = new BehaviorDelegate(EnemyBehavior); InitializeAI(); break; case PoleType.NeutralStatic: AIBehave = new BehaviorDelegate(NeutralStaticBehavior); InitializeAI(); break; case PoleType.NeutralMovable: AIBehave = new BehaviorDelegate(NeutralStaticBehavior); InitializeAI(); break; default: break; } // POLE ASSEMBLY TRANSFORM INIT poleAssemblyTransform = poleAssembly.GetComponent <Transform>(); // POLE HEIGHT LIMIT AND PARAM INIT poleModelRelationHeightTop = poleAssemblyTransform.position.y - transform.position.y; poleModelRelationHeightBottom = poleModelRelationHeightTop - poleParams.poleModelMaxRelationHeightDiff; // EFFECTS INIT foreach (Transform child in gameObject.GetComponentsInChildren <Transform>()) { switch (child.gameObject.name) { case "DownEngineFire": downEngineFire = child.gameObject; break; case "UpEngineFire": upEngineFire = child.gameObject; break; case "RightEngineFire": rightEngineFire = child.gameObject; break; case "LeftEngineFire": leftEngineFire = child.gameObject; break; case "BodyDamagedLightning": bodyDamagedLightning = child.gameObject; break; case "EngineDamagedLightning": engineDamagedLightning = child.gameObject; break; case "SensorDamagedLightning": sensorDamagedLightning = child.gameObject; break; default: break; } } var leftEngineFireEmission = leftEngineFire.GetComponent <ParticleSystem>().emission; var rightEngineFireEmission = rightEngineFire.GetComponent <ParticleSystem>().emission; var upEngineFireEmission = upEngineFire.GetComponent <ParticleSystem>().emission; var downEngineFireEmission = downEngineFire.GetComponent <ParticleSystem>().emission; leftEngineFireEmission.enabled = false; rightEngineFireEmission.enabled = false; upEngineFireEmission.enabled = false; downEngineFireEmission.enabled = false; var bodyDamagedLightningEmission = bodyDamagedLightning.GetComponent <ParticleSystem>().emission; var engineDamagedLightningEmission = engineDamagedLightning.GetComponent <ParticleSystem>().emission; var sensorDamagedLightningEmission = sensorDamagedLightning.GetComponent <ParticleSystem>().emission; bodyDamagedLightningEmission.enabled = false; engineDamagedLightningEmission.enabled = false; sensorDamagedLightningEmission.enabled = false; // SOUND INIT antigravityEngineSound = gameObject.GetComponent <AudioSource>(); }
private void BarPrevious(object sender, MouseButtonEventArgs e) { BarControl.Previous(ExamplesMapper.BarExamples); }
private void BarNext(object sender, MouseButtonEventArgs e) { BarControl.Next(ExamplesMapper.BarExamples); }
public virtual void Awake() { barObj = Instantiate(barPrefab, GameObject.Find("Bar Parent").transform); barObj.GetComponent <UIFollowObject>().target = gameObject; bar = barObj.GetComponentInChildren <BarControl>(); }