void GrabEnter() { //mRightHand.renderer.enabled = true; mRightState = MState.Attacking; if (mGrabItem == null) { float closestEnemyDist = Mathf.Infinity; Vector3 grabPos = mRightHand.position; Collider closestEnemy = null; Collider[] colliders = Physics.OverlapSphere(grabPos, mGrabRadius); foreach (Collider hit in colliders) { Vector3 forward = mTransform.TransformDirection(Vector3.forward); Vector3 toOther = hit.transform.position - mTransform.position; if (hit.rigidbody && hit.tag == "Enemy" && Vector3.Dot(forward, toOther) > 0) { Vector3 closestPoint = hit.ClosestPointOnBounds(mRightHand.position); float tempDistance = CalculateDistance(closestPoint, mRightHand); if (tempDistance < closestEnemyDist) { closestEnemyDist = tempDistance; closestEnemy = hit; } } } if (closestEnemy != null) { mGrabItem = closestEnemy.transform; mGrabItem.SendMessage("OnGrabbed"); } } }
public override void Run(MState state, Stack <byte> args) { int address = args.Pop(); state.StackFrames.Push(new StackFrame(state.IP)); // Push a new stack frame state.IP = address - 1; }
public override void Run(MState state, Stack <byte> args) { int returnAddress = state.CurrentStackFrame.ReturnAddress; state.StackFrames.Pop(); state.IP = returnAddress; }
//Updates the boss's position based on current state according to MState state mahine public override void UpdatePosition() { if (isEntering && X > windowWidth / 2) { X = Convert.ToInt32(X - speed); return; } isEntering = false; actionTimer += 0.01; switch (currentState) { case MState.Start: start(); if (health < (max / 2)) { currentState = MState.Mid; reset = 50; } break; case MState.Mid: Mid(); break; case MState.Attack: Attack(); break; } hitbox.X = Convert.ToInt32(X); hitbox.Y = Convert.ToInt32(Y); }
//At MState.Attack, move forward until reaching zero then returning to previous position //and state private void Attack() { FiredABullet = false; if (!goingBackwards && X > 0) { X = Convert.ToInt32(X - speed); return; } goingBackwards = true; if (X <= windowWidth / 2) { X = Convert.ToInt32(X + speed); } else { goingBackwards = false; if (health < (max / 2)) { currentState = MState.Mid; } else { currentState = MState.Start; } } }
public override void Run(MState state, Core.Stack <byte> args) { var f = state.Stack.Pop(); var s = state.Stack.Pop(); state.Stack.Push(f == s); }
private void CustomForm_MouseDown(object sender, MouseEventArgs e) { if (WindowState != FormWindowState.Maximized) { MState.SetData(this.Bounds, Cursor.Position); } }
public async UniTaskVoid Init() { DontDestroyOnLoad(this); GameTime.Init(DateTime.Now.Second); // UpdateTextUI ("Loading assets..."); await assets.Init(Progress.Create <float> (x => UpdateProgressUI(x))); // UpdateTextUI ("Loading network..."); await network.Init(Progress.Create <float> (x => UpdateProgressUI(x))); // UpdateTextUI ("Loading game data..."); await data.Init(Progress.Create <float> (x => UpdateProgressUI(x))); // UpdateTextUI ("Loading profile..."); await player.Init(Progress.Create <float> (x => UpdateProgressUI(x))); await enemy.Init(Progress.Create <float> (x => UpdateProgressUI(x))); //UpdateTextUI ("Loading scene..."); Scene s = SceneManager.GetActiveScene(); if (s.name != "Main") { await SceneManager.LoadSceneAsync("Main").ToUniTask(Progress.Create <float> (x => UpdateProgressUI(x))); } //await UniTask.DelayFrame (2); //UpdateProgressUI (1); state = MState.INITED; OnInited?.Invoke(); }
public void joinServer(string ip) { state = MState.CONNECTING; StatusLabel.text = "CONNECTING TO "+ip; PhotonNetwork.JoinRoom(ip); /* // Validate IP try { NetworkConnectionError error = Network.Connect( ip,DEFAULT_PORT); if( error != NetworkConnectionError.NoError) { StatusLabel.text = "Error connecting to Server"; state = MState.IDLE; } else { // nothing goes wrong so far, waiting } } catch(System.Exception e)// NetworkConnectionError { StatusLabel.text = "Failed to Connect to Server"; state = MState.IDLE; }*/ }
private void CustomForm_MouseMove(object sender, MouseEventArgs e) { if (!this.Capture && WindowState != FormWindowState.Maximized) { MState.SetState(this.setMouse(e.Location)); return; } }
public override void Run(MState state, Core.Stack <byte> args) { var val = state.Stack.Pop(); if (val) { state.IP = args.Pop() - 1; } }
public override void Run(MState state, Stack <byte> args) { var lhs = state.Stack.Pop(); var rhs = state.Stack.Pop(); var result = lhs + rhs; state.Stack.Push(result); }
IEnumerator TurnIdle() { yield return(new WaitForSeconds(.5f)); if (_cMState == MState.Up) { _cMState = MState.Idle; } }
IEnumerator GoBackUp() { yield return(new WaitForSeconds(2f)); if (_cMState == MState.Down) { _cMState = MState.Up; } }
void GrabExit() { if (this.mGrabItem != null) { mGrabItem.SendMessage("OnReleased"); } //mRightHand.renderer.enabled = false; mRightState = MState.Idle; mGrabItem = null; mGrabTimer = 0; }
public override void Run(MState state, Stack <byte> args) { var val = state.Stack.Pop(); var arg = args.Pop(); if (state.CurrentStackFrame.Locals.Count > arg) { state.CurrentStackFrame.Locals.Add(val); } else { state.CurrentStackFrame.Locals[arg] = val; } }
//At MState.Start, move up and down game screen while shooting at an average rate //Randomly set MState to Attack private void start() { if (Y < 0 || Y > windowHeight - hitbox.Y) { dir *= -1; } Y = Convert.ToInt32(Y + (dir * speed)); Shoot(); if (random.Next(0, 1000) == 4) { currentState = MState.Attack; } }
void Raycasting() { Debug.DrawLine(sightStart.position, sightEnd.position, Color.green); RaycastHit2D hit = Physics2D.Linecast(sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer("Player")); if (hit) { if (hit.collider.tag == "Player" && _cMState == MState.Idle) { _cMState = MState.Down; endPos = new Vector3(hit.transform.position.x, hit.transform.position.y - 0, hit.transform.position.z); StartCoroutine(GoBackUp()); } } }
//At MState.Mid, track player's position and shoot at faster average rate //Randomly set MState to Attack private void Mid() { if (Y < (p_y - 100)) { Y = (Y + (0.5 * speed)); } else if (Y > (p_y - 100)) { Y = (Y - (0.5 * speed)); } Shoot(); if (random.Next(0, 1000) == 4) { currentState = MState.Attack; } }
void AttackEnter() { //mLeftHand.renderer.enabled = true; mLeftState = MState.Attacking; PunchParticle.Play(); if (LeftHand == true) { PlayerPunch.LeftPunch(); } else { PlayerPunch.RightPunch(); } LeftHand = !LeftHand; //mLeftHand.collider.enabled = true; Vector3 punchPos = mLeftHand.position; Collider[] colliders = Physics.OverlapSphere(punchPos, mPunchRadius); foreach (Collider hit in colliders) { Vector3 forward = mTransform.TransformDirection(Vector3.forward); Vector3 toOther = hit.transform.position - mTransform.position; if (hit.rigidbody && hit.tag == "Enemy" && Vector3.Dot(forward, toOther) > 0f) { //Knock Enemy back float distance = Vector3.Magnitude(hit.transform.position - mLeftHand.position); float punchPower = Mathf.Min(mMaxPunchPower / distance, mMinPunchPower); hit.rigidbody.AddForce((Vector3.Normalize(hit.transform.position - mLeftHand.position)) * punchPower, ForceMode.Impulse); hit.gameObject.SendMessage("OnHit"); hit.gameObject.SendMessage("OnDamaged", mPunchDamage); //Increment pulse power mPlayer.GetComponent <Player>().PulsePower += mPulseBonus; mCamera.GetComponent <GameStatsUI>().pulsePoints += mPulseBonus; } } }
void Awake() { state = MState.INITIALIZATING; if (instance == null) { instance = this; player = GetComponent <PlayerManager> (); data = GetComponent <GameDataManager> (); network = GetComponent <NetworkManager> (); assets = GetComponent <AssetsManager> (); enemy = GetComponent <EnemyManager> (); // DontDestroyOnLoad (gameObject); } else { DestroyImmediate(gameObject); } }
// Use this for initialization void Start () { PhotonNetwork.ConnectUsingSettings("1.0"); Debug.Log ((PhotonNetwork.connectionStateDetailed.ToString())); //lanbs = transform.GetComponent<LANBroadcastService>(); state = MState.IDLE; quickip = ""; // test json /* JSONData a1 = new JSONData("haha"); JSONData a2 = new JSONData(2); JSONClass cl = new JSONClass(); cl.Add("a1",a1); cl.Add ("a2",a2); string jsonstr = cl.SaveToBase64(); Debug.Log (jsonstr); Debug.Log (JSONNode.LoadFromBase64(jsonstr)); */ }
void OnFailedToConnect(NetworkConnectionError error) { StatusLabel.text = "Error connecting to Server"; state = MState.IDLE; }
void OnPhotonJoinRoomFailed() { StatusLabel.text = "Error connecting to Server"; state = MState.IDLE; }
int reset = 60; //Rate of bullet fire //Constructor taking in //X position, Y position, initil health, Window height, and window width public Boss_Easy(double X, double Y, int health, double winWidth, double winHeight) : base(X, Y, health, winWidth, winHeight) { currentState = MState.Start; }
public virtual void ChangeState(MState <GameObject> state, bool isSame = false) { this.stateMachine.ChangeState(state, isSame); }
public void Write(TPNumber E) { FNumber = E.Copy(); FState = MState._On; }
private void CustomForm_MouseUp(object sender, MouseEventArgs e) { if (WindowState != FormWindowState.Maximized) { int dx = 0; int dy = 0; int dr = 0; int db = 0; Point cp = Cursor.Position; if (MState.LastState == MouseAction.Left) { dx = cp.X - MState.LastX; } else if (MState.LastState == MouseAction.Right) { dr = cp.X - MState.LastX; } else if (MState.LastState == MouseAction.Top) { dy = cp.Y - MState.LastY; } else if (MState.LastState == MouseAction.Bottom) { db = cp.Y - MState.LastY; } else if (MState.LastState == MouseAction.LeftTop) { dx = cp.X - MState.LastX; dy = cp.Y - MState.LastY; } else if (MState.LastState == MouseAction.RightTop) { dr = cp.X - MState.LastX; dy = cp.Y - MState.LastY; } else if (MState.LastState == MouseAction.LeftBottom) { dx = cp.X - MState.LastX; db = cp.Y - MState.LastY; } else if (MState.LastState == MouseAction.RightBottom) { dr = cp.X - MState.LastX; db = cp.Y - MState.LastY; } int left = MState.Left + dx; int top = MState.Top + dy; int right = MState.Right + dr; int bottom = MState.Bottom + db; if (dx != 0) { if (left >= this.Right - MinimumSize.Width) { left = this.Right - MinimumSize.Width; } } if (dy != 0) { if (top >= this.Bottom - MinimumSize.Height) { top = this.Bottom - MinimumSize.Height; } } if (dr != 0) { if (right <= this.Left + MinimumSize.Width) { right = this.Left + MinimumSize.Width; } } if (db != 0) { if (bottom <= this.Top + MinimumSize.Height) { bottom = this.Top + MinimumSize.Height; } } this.Bounds = Rectangle.FromLTRB(left, top, right, bottom); this.Size = new Size(this.Bounds.Width, this.Bounds.Height); this.Invalidate(); MState.ResetState(); } this.Cursor = Cursors.Default; }
internal static void SaveMemregState(SearchEntry entry, int memreg, MemReg mr) { entry.isState=true; MState current=entry.mCurrent; if(current==null) { MState head=entry.mHead; if(head==null) entry.mHead=entry.mCurrent=current=new MState(); else current=head; } else { MState next=current.next; if(next==null){ current.next=next=new MState(); next.prev=current; } current=next; } current.index=memreg; current._in=mr._in; current._out=mr._out; entry.mCurrent=current; }
// Update is called once per frame void Update () { if(state==MState.IDLE) { state = MState.SEARCHING; //lanbs.StartSearchBroadCasting(OnFoundServer,OnNotFoundServer); } }
void OnNotFoundServer() { state = MState.IDLE; }
void AttackExit() { mLeftHand.renderer.enabled = false; mLeftState = MState.Idle; mPunchTimer = 0; }
public override void Run(MState state, Stack <byte> args) { //ToDo: fix jump instruction state.IP = args.Pop() - 1; }
void OnJoinedRoom() { Debug.Log ("someone join"); if(!PhotonNetwork.isMasterClient) { Debug.Log ("it's the client"); // we are the client StatusLabel.text = "Connected"; state = MState.STARTING; Application.LoadLevel("Scene_TestCameraHUD"); } }
void OnConnectedToServer() { // Connected StatusLabel.text = "Connected"; state = MState.STARTING; Application.LoadLevel("Scene_TestCameraHUD"); }
void OnPhotonPlayerConnected(PhotonPlayer otherPlayer) { Debug.Log ("client join"); if(PhotonNetwork.isMasterClient) { StatusLabel.text = "Client connected"; state = MState.STARTING; Application.LoadLevel("Scene_TestCameraHUD"); } }
public override void Run(MState state, Stack <byte> args) { Native.Int(0x80); }
public void Clear(TPNumber E) { FNumber.Reset(); FNumber.systemBase = E.systemBase; FState = MState._Off; }
public override void Run(MState state, Stack <byte> args) { var val = state.Stack.Pop(); //Screen.WriteLine(val.ToString()); }
void OnTriggerEnter2D() { _cMState = MState.Up; }
// Utility method for performing the state delegate swapping logic based on an enum value void SwitchCurrentState(MState state) { this.mState = state; switch (mState) { case MState.None: currentStateMethod = null; break; case MState.Entering: currentStateMethod = this.enter; break; case MState.Exiting: currentStateMethod = this.exit; break; case MState.Updating: currentStateMethod = this.update; break; } }
void OnPlayerConnected(NetworkPlayer player) { Debug.Log("Player connected from " + player.ipAddress + ":" + player.port); StatusLabel.text = "Client connected"; state = MState.STARTING; Application.LoadLevel("Scene_TestCameraHUD"); }
public void StartStopServer() { if(state==MState.LISTENING) { //lanbs.StopBroadCasting(); PhotonNetwork.LeaveRoom(); StatusLabel.text = "Server stopped"; StartStopServerLabel.text = "Start Server"; state = MState.IDLE; } else { string svname = "server"+Random.Range(10000,100000); PhotonNetwork.CreateRoom(svname,false,true,2); pcount = 0; //Network.InitializeServer(2,DEFAULT_PORT,true); //lanbs.StartAnnounceBroadCasting(); StatusLabel.text = "Waiting for connection with name "+svname; StartStopServerLabel.text = "Stop Server"; state = MState.LISTENING; } }