private int Vic_ReadMemory(int addr) { // the system sees (cia1.PortAData & 0x3) but we use a shortcut _lastReadVicAddress = addr | _vicBank; _lastReadVicData = Pla.VicRead(_lastReadVicAddress); return(_lastReadVicData); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D> (); target = GameObject.FindObjectOfType <Pla>(); moveDirection = (target.transform.position - transform.position).normalized * moveSpeed; rb.velocity = new Vector2(moveDirection.x, moveDirection.y); Destroy(gameObject, 3f); }
// Use this for initialization void Start() { TG[0].onValueChanged.AddListener(onValueChanged0); TG[1].onValueChanged.AddListener(onValueChanged1); TG[2].onValueChanged.AddListener(onValueChanged2); pp = Planet.GetComponent <Pla>(); gap = (float)1 / Images.Length; for (int i = 0; i < Images.Length; i++) { Images[i].anchoredPosition = new Vector2(gap * (0.5f + i) * Planet.rect.width, 0); } }
private void Cpu_WriteMemoryPort(int addr) { Pla.WriteMemory(addr, ReadOpenBus()); }
// Update is called once per frame void Update () { if (work) { if (Input.GetKeyUp (KeyCode.Escape)) { Application.Quit (); } Vector3 plpos; RaycastHit hit; Ray _ray = Camera.main.ScreenPointToRay (Input.mousePosition); sending = false; //////////////////////////////////////////////////////////////////////////////////////////// ////////////////////// ВЫДЕЛЕНИЕ ОБЪЕКТА //////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (Input.GetMouseButtonUp (0) && mylive) { if (Physics.Raycast (_ray, out hit, Mathf.Infinity, masks1)) { for (int i = 0; i < Mobs.Count; i++) { if (Mobs [i].gm == hit.transform.gameObject) { if (targetNumber == Mobs [i].index) { useskill = 2; } else { targetNumber = Mobs [i].index; i = Mobs.Count; } } } } else { if (Physics.Raycast (_ray, out hit, Mathf.Infinity, masks2)) { str = "Motion|" + hit.point.x + "|" + hit.point.y + "|" + hit.point.z + "|"; sending = true; } } } //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////// ОТОБРАЖЕНИЕ ТАРГЕТ ПАНЕЛИ //////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (targetNumber > -1) { targetPanel.SetActive (true); targetText.text = Mobs [MobMassIndex.IndexOf (targetNumber)].name; targetHP.fillAmount = Mobs [MobMassIndex.IndexOf (targetNumber)].hp / Mobs [MobMassIndex.IndexOf (targetNumber)].max_hp; } else { targetPanel.SetActive (false); } //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////// ДВИЖЕНИЕ //////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (doing == Pla.walk) { inplace = true; movetarget.SetActive (false); status = Stat.Idle; } if (doing == Pla.Persecution) { inplace = false; target = Mobs [targetNumber2].gm.transform.position; status = Stat.Run; movetarget.SetActive (false); } if (!inplace) { if (Vector3.Distance (this.transform.position, target) <= 1.3f) { inplace = true; movetarget.SetActive (false); status = Stat.Idle; doing = Pla.walk; } else { direction = target - this.transform.position; direction = new Vector3 (direction.x, 0, direction.z); direction.Normalize (); player.Move (direction * Time.deltaTime * speed); Quaternion look = Quaternion.LookRotation (direction); this.transform.rotation = Quaternion.Slerp (this.transform.rotation, look, Time.deltaTime * speedRotation); } } //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////// ОБРАБОТКА АТАКИ //////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// /*if (Input.GetButtonDown("Fire1")){ float zz=10; int i,j=0; for(i = 0;i<Mobs.Count; i++){ if(Vector3.Distance(thisTran.position,Mobs[i].gm.transform.position) < zz){ j=i; zz =Vector3.Distance(thisTran.position,Mobs[i].gm.transform.position); } } str="Attack|"+Mobs[j].index+"|"; sending = true; }*/ //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////// ОБРАБОТКА МЕНЮ //////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (menudown == 1 && !mylive) { str = "Resurrection|"; sending = true; } //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////// ОБРАБОТКА СКИЛЛА //////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if ((Input.GetKeyDown (KeyCode.F1) || useskill == 1) && mylive) { str = "UseSkill|Blink|"; sending = true; doing = Pla.walk; } if ((Input.GetKeyDown (KeyCode.F2) || useskill == 2) && mylive) { str = "Attack|" + Mobs [MobMassIndex.IndexOf (targetNumber)].index + "|"; sending = true; } if (Input.GetKeyDown (KeyCode.F3) || useskill == 3) { int j, i, k; bool n; float zz = 10, ff = 10; newMass.Clear (); for (i = 0; i < Mobs.Count; i++) { Mobs [i].dist = Vector3.Distance (thisTran.position, Mobs [i].gm.transform.position); if (Mobs [i].dist < zz) { newMass.Add (i); } } k = 0; n = false; if (newMass.Count != 0) { if (newMass.Count == lastMass.Count) { for (i = 0; i < newMass.Count; i++) { for (j = 0; j < newMass.Count; j++) { if (newMass [i] == lastMass [j]) { k++; } } } if (k == newMass.Count) { n = true; } else { lastMass = newMass; } } else { lastMass = newMass; } if (n) { dopNumber++; if (dopNumber >= lastMass.Count) { dopNumber = 0; } targetNumber = Mobs [lastMass [dopNumber]].index; } else { for (i = 0; i < lastMass.Count; i++) { ff = 10; for (j = 0; j < newMass.Count; j++) { if (Mobs [newMass [j]].dist < ff) { ff = Mobs [newMass [j]].dist; k = j; } } lastMass [i] = newMass [k]; Mobs [newMass [k]].dist = 100; } dopNumber = 0; targetNumber = Mobs [lastMass [0]].index; } } } //////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////// ОБЫЧНОЕ СООБШЕНИЕ //////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (!sending) { str = "MyUPD|" + thisTran.position.x + "|" + thisTran.position.y + "|" + thisTran.position.z + "|" + thisTran.rotation.eulerAngles.y + "|"; } //////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// ОБРАБОТКА ОТВЕТА //////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (!DEBAG) { datatext = conectscript.sendmessage (str);// ОТПРАВКА //print (datatext); if (getdat () == "AllUPD") { rem (); if (getdat () == "Persecution") { rem (); doing = Pla.Persecution; targetN = int.Parse (getdat ()); rem (); } if (getdat () == "Motion") { rem (); doing = Pla.run; target = new Vector3 (float.Parse (getdatrem ()), float.Parse (getdatrem ()), float.Parse (getdatrem ())); inplace = false; movetarget.SetActive (true); movetarget.transform.position = target; status = Stat.Run; } plpos.x = float.Parse (getdatrem ()); plpos.y = float.Parse (getdatrem ()); plpos.z = float.Parse (getdatrem ()); hp = float.Parse (getdatrem ()); max_hp = float.Parse (getdatrem ()); thisTran.position = plpos; if ((int.Parse (getdatrem ())) == 0) { mylive = false; } else { mylive = true; } mobnumbers = int.Parse (getdat ()); MobMassIndex.Clear (); for (int i = 0; i < mobnumbers; i++) { rem (); MobMassIndex.Add (int.Parse (getdat ())); } for (int i = 0; i < mobnumbers || i < Mobs.Count; i++) { if (i + 1 > Mobs.Count) { Mobs.Add (new Mob (Instantiate (kobj, new Vector3 (0, -10, 0), transform.rotation) as GameObject)); } else { if (!MobMassIndex.Contains (Mobs [i].index)) { if (targetNumber == Mobs [i].index) { targetNumber = -1; } Destroy (Mobs [i].gm); Mobs.RemoveAt (i); i--; } } } for (int i = 0; i < mobnumbers; i++) { rem (); Mobs [i].index = int.Parse (getdatrem ()); if (Mobs [i].index == targetN) { targetNumber2 = i; } Mobs [i].name = getdatrem (); plpos.x = float.Parse (getdatrem ()); plpos.y = float.Parse (getdatrem ()); plpos.z = float.Parse (getdatrem ()); rem (); Mobs [i].gm.transform.position = plpos; Mobs [i].hp = float.Parse (getdatrem ()); Mobs [i].max_hp = float.Parse (getdat ()); Mobs [i].script.hp = Mobs [i].hp; Mobs [i].script.textname.text = Mobs [i].name; Mobs [i].script.max_hp = Mobs [i].max_hp; if (Mobs [i].hp <= 0 && Mobs [i].live == true) { Mobs [i].gm.SetActive (false); Mobs [i].script.text.SetActive (false); Mobs [i].script.hpb.SetActive (false); Mobs [i].live = false; } if (Mobs [i].live == false && Mobs [i].hp > 0) { Mobs [i].gm.SetActive (true); Mobs [i].script.text.SetActive (true); Mobs [i].script.hpb.SetActive (true); Mobs [i].live = true; } } rem (); playernumbers = int.Parse (getdat ()); for (int i = 0; i < playernumbers; i++) { if (Players.Count < playernumbers) { Players.Add (new Player (Instantiate (playerobj, new Vector3 (0, 0, 0), transform.rotation) as GameObject)); } rem (); Players [i].index = int.Parse (getdatrem ()); if (Players [i].index == targetN) { targetNumber2 = i; } plpos.x = float.Parse (getdatrem ()); plpos.y = float.Parse (getdatrem ()); plpos.z = float.Parse (getdatrem ()); Players [i].gm.transform.rotation = Quaternion.Euler (0, float.Parse (getdatrem ()), 0); Players [i].gm.transform.position = plpos; Players [i].hp = float.Parse (getdatrem ()); Players [i].max_hp = float.Parse (getdat ()); } hpbar.fillAmount = hp / max_hp; tex.text = hp + "\\" + max_hp; if (targetNumber > -1) { Mobs [MobMassIndex.IndexOf (targetNumber)].script.textname.text = "* " + Mobs [MobMassIndex.IndexOf (targetNumber)].name + " *"; } } } if (!mylive) { PanelRes.SetActive (true); } else { PanelRes.SetActive (false); } //////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// АНИМАЦИЯ //////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// if (status == Stat.Idle) { _animation.Play ("idle", PlayMode.StopAll); _animation.CrossFade ("run"); } if (status == Stat.Run) { _animation.Play ("run", PlayMode.StopAll); _animation.CrossFade ("idle"); } useskill = 0; menudown = 0; } }
private void Cpu_WriteMemoryPort(int addr, int val) { Pla.WriteMemory(addr, Bus); }