void move() { if (Input.GetMouseButton(0) && !isEnemy) { Vector3 mouse = Input.mousePosition; Ray ray = Camera.main.ScreenPointToRay(mouse); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Debug.Log(hit.transform.tag); if (hit.transform.gameObject.layer == 10 && Vector3.Distance(hit.transform.position, transform.position) <= distanceRange) { AliveObject tmp = hit.transform.gameObject.GetComponent <AliveObject>(); if (!tmp.isDead && tmp.isSpawn) { _targetEnemy = tmp; mouseTarget.target = _targetEnemy; mouseTarget.isTarget = true; transform.LookAt(_targetEnemy.gameObject.transform.position); attackAnimationStart(); } } else if (hit.transform.tag == "Weapon" && Vector3.Distance(hit.transform.position, transform.position) <= distanceRange) { PickUpItem(hit.transform.gameObject); } else if (hit.transform.gameObject.layer != 5) { _moveOnPosition(hit.point); } } } }
/// <summary> /// Привязываем камеру к "живому" объекту /// </summary> /// <param name="obj">Объект</param> public void Tracking(AliveObject obj) { if (BindedObject != obj) { BindedObject = obj; } }
private async void AliveSendTimer_Elapsed(object sender, ElapsedEventArgs e) { try { if (!Connected || !State.SystemsAlive) { return; } var ao = new AliveObject { Ticks = TLCFIClient.CurrentTicks, Time = TimestampGenerator.GetTimestamp() }; var reply = await TLCProxy.AliveAsync(ao, _sessionCancellationToken); if (reply != null && reply.Ticks == ao.Ticks && reply.Time == ao.Time) { return; } _aliveSendFailCounter++; if (_aliveSendFailCounter > 2) { StopAliveTimers(); SendAliveTimeoutOccured?.Invoke(this, EventArgs.Empty); } } catch { // ignored } }
// Update is called once per frame void Update() { mouse = Input.mousePosition; mouse.z = 10; ray = Camera.main.ScreenPointToRay(mouse); //Debug.DrawRay(ray.origin, ray.direction * 10, Color.blue); if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject.tag == "EnemyObject") { GamaManager.gm.target(hit.transform.gameObject.GetComponent <AliveObject>()); } else if (isTarget) { GamaManager.gm.target(target); if (target.hp <= 0) { isTarget = false; target = null; } } else { GamaManager.gm.targetViewEnemy(false); } } }
internal void updateObjLoc(AliveObject tob) { float x, y; myDog.Coordinates(out x, out y); tob.X = x; tob.Y = y; }
private void dropobjectbutton_Click(object sender, EventArgs e) { if (carriedPrim != null) { myAvatar.DropObject(carriedPrim); carriedPrim = null; } }
private IConnection GetConnection() { _connectionLazy = SingletonLocker.Lock(ref _connectionLazy, () => new AliveObject <IConnection>(() => CreateConnectionFactory().CreateConnection(), new AliveCheckPolicy <IConnection>(s => s.IsOpen, TimeSpan.FromSeconds(5)))); return(_connectionLazy.Value); }
public void target(AliveObject enemy) { targetViewEnemy(true); hpEnemy.maxValue = enemy.maxHp; hpEnemy.value = enemy.hp; textHpEnemy.text = enemy.hp.ToString(); textLvlEnemy.text = "Lv." + enemy.level; textTargetEnemyName.text = enemy.GetTypeObject(); }
public override void action(AliveObject alive) { if (isActive) { _alive = alive; isActive = false; isHealing = true; oldTimeActivate = Time.time; timeToEnd = Time.time; } }
public override void action(AliveObject aliveObject) { if (isActive && GamaManager.gm.pc.getSpeed() == 0.0f) { if (aliveObject.hp > 0) { _aliveObject = aliveObject; } isReady = true; areaRange.SetActive(true); area.SetActive(true); } }
public void drop_it() { AliveObject target = myMind.myContext.carried_object; if (target == null) { } //myMind.mySynth.SpeakAsync("I am not carrying anything"); else { myMind.myDog.DropObject(target); myMind.myContext.carried_object = null; } }
public override void action(AliveObject aliveObject) { if (isActive) { if (aliveObject.hp > 0) { GameObject fireballObject = Instantiate(fireball, transform.position, Quaternion.identity); fireballObject.SendMessage("fly", gameObject); isActive = false; oldTimeActivate = Time.time; } } }
private void removeObstacle(AliveObject fob) { for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { if (obstacleMap[i, j] == fob) { obstacleMap[i, j] = null; } } } }
public override void action(AliveObject aliveObject) { if (isActive) { if (aliveObject.hp > 0) { _aliveObject = aliveObject; } isActive = false; isRotate = true; oldTimeActivate = Time.time; } }
private bool next_to(int x, int y, AliveObject target) { if (dogTricks.distance(x, y, target.X, target.Y) < 2) { return(true); } int dx = Math.Sign(target.X - x); int dy = Math.Sign(target.Y - y); if (myMind.obstacleMap[x + dx, y + dy] == target) { return(true); } return(false); }
void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Enemy" && Hero.instance.Motor._attacks) { AliveObject enemyManager = collision.transform.gameObject.GetComponent <AliveObject>(); if (enemyManager == null) { Debug.LogWarning("Не найден менеджер врага"); return; } var _currentAttackItem = _attackItems.Where(x => x._ID == Hero.instance.Motor.AttackIndex).FirstOrDefault(); enemyManager.TakeHit(_currentAttackItem._damage, _currentAttackItem._ID); } }
public async Task <AliveObject> AliveAsync(AliveObject alive, CancellationToken token) { try { return(await _rpcClient.InvokeAsync <AliveObject>("Alive", alive, _aliveReceiveTimeOut, token)); } catch (JsonRpcException e) { _logger.Error(e, "Calling method AliveAsync failed: {0}. Exception: ", e.RpcMessage); throw; } catch (Exception e) { _logger.Error(e, "Calling method AliveAsync failed: "); throw; } }
private void takeobjectbutton_Click(object sender, EventArgs e) { if (objectidbox.Text != null) // try to guard against empty textbox { int objectIndex = Convert.ToInt32(objectidbox.Text); if (Prims.Count >= objectIndex) // try to guard against bad index { if (myAvatar.PickupObject(Prims[objectIndex])) { carriedPrim = Prims[objectIndex]; } else { carriedPrim = null; } } } }
public override void action(AliveObject aliveObject) { if (isActive) { float hp = aliveObject.hp; float maxHp = aliveObject.maxHp; if (hp > 0) { hp = hp + (maxHp * powerRegen); if (hp > maxHp) { hp = maxHp; } aliveObject.hp = System.Convert.ToInt32(hp); } isActive = false; oldTimeActivate = Time.time; _ps.Play(); } }
public void pick_it_up() { AliveObject target = myMind.myContext.last_focus; if (target == null) { } //myMind.mySynth.SpeakAsync("I don't remember the target"); else { if (myMind.myDog.PickupObject(target)) { myMind.myContext.carried_object = target; } else { myMind.myContext.carried_object = null; // myMind.mySynth.SpeakAsync("I cannot pick up the target"); } } }
private void update_obstacleMap(AliveObject fob) { double w, d, r, xc, yc, x1, y1, x2, y2, angle, delta; int xleft, ybot, xright, ytop; w = fob.width / 2; d = fob.depth / 2; r = Math.Sqrt(w * w + d * d); if (r < .35) { return; // small objects are not obstacles } xc = fob.X; yc = fob.Y; angle = Math.PI * fob.angle / 180; delta = 1.1; xleft = (int)Math.Max(Math.Floor(xc - r), 0); ybot = (int)Math.Max(Math.Floor(yc - r), 0); xright = (int)Math.Min(Math.Ceiling(xc + r), 255); ytop = (int)Math.Min(Math.Ceiling(yc + r), 255); for (int x = xleft; x <= xright; x++) { for (int y = ybot; y <= ytop; y++) { x1 = x - xc; y1 = y - yc; x2 = x1 * Math.Cos(angle) + y1 * Math.Sin(angle); y2 = -x1 *Math.Sin(angle) + y1 * Math.Cos(angle); if (Math.Abs(x2) < w + delta && Math.Abs(y2) < d + delta) { obstacleMap[x, y] = fob; exploredMap[x, y] = true; } } } }
public void report() { string message = ""; foreach (DictionaryEntry i in myMind.knownObjects) { string fam = (string)i.Key; Hashtable famObjs = (Hashtable)i.Value; if (famObjs == null) { break; } int c = famObjs.Count; if (c == 0) { break; } string plural = ""; if (c > 1) { plural = "s"; } message = message + "I see " + c.ToString() + " " + fam + plural + "\r\n"; foreach (DictionaryEntry j in famObjs) { AliveObject obj = (AliveObject)j.Value; string name = obj.name; string x = obj.X.ToString(); string y = obj.Y.ToString(); string color = obj.color; string height = obj.height.ToString(); string width = obj.width.ToString(); message = message + " " + name + " " + color + " at (" + x + " , " + y + ") height = " + height + " width = " + width + "\r\n"; } } Console.WriteLine(message); }
public walkPath(float xc, float yc, AliveObject target, DogsMind mind) { min_x = mind.min_x; min_y = mind.min_y; max_x = mind.max_x; max_y = mind.max_y; myMind = mind; int[] node; path = new ArrayList(); open = new ArrayList(); backmapX = new int[256, 256]; backmapY = new int[256, 256]; myMind.freeGridPoint(xc, yc, out start_x, out start_y); end_x = (int)target.X; end_y = (int)target.Y; if (start_x < min_x || start_y < min_y || end_x < min_x || end_y < min_y || start_x > max_x || start_y > max_y || end_x > max_x || end_y > max_y) { return; } if (start_x == end_x && start_y == end_y) { return; } backmapX[start_x, start_y] = start_x; backmapY[start_x, start_y] = start_y; node = new int[2] { start_x, start_y }; open.Add(node); if (buildBackMaps(target) == false) { return; // can't get there } buildPath(); }
private bool buildBackMaps(AliveObject target) { if (open.Count == 0) { return(false); } int[] c_node = (int[])open[0]; int cx = c_node[0]; int cy = c_node[1]; if (next_to(cx, cy, target) || dogTricks.distance(cx, cy, target.X, target.Y) < 1.5) { end_x = cx; end_y = cy; return(true); } open.RemoveAt(0); if (cx + 1 <= max_x && myMind.obstacleMap[cx + 1, cy] == null) { updOpen(cx, cy, 1, 0); if (cy + 1 <= max_y && myMind.obstacleMap[cx + 1, cy + 1] == null) { updOpen(cx, cy, 1, 1); } if (cy - 1 >= min_y && myMind.obstacleMap[cx + 1, cy - 1] == null) { updOpen(cx, cy, 1, -1); } } if (cx - 1 >= min_x && myMind.obstacleMap[cx + 1, cy] == null) { updOpen(cx, cy, -1, 0); if (cy + 1 <= max_y && myMind.obstacleMap[cx - 1, cy + 1] == null) { updOpen(cx, cy, -1, 1); } if (cy - 1 >= min_y && myMind.obstacleMap[cx - 1, cy - 1] == null) { updOpen(cx, cy, -1, -1); } } if (cy + 1 <= max_x && myMind.obstacleMap[cx, cy + 1] == null) { updOpen(cx, cy, 0, 1); if (cx + 1 <= max_x && myMind.obstacleMap[cx + 1, cy + 1] == null) { updOpen(cx, cy, 1, 1); } if (cx - 1 >= min_x && myMind.obstacleMap[cx - 1, cy + 1] == null) { updOpen(cx, cy, -1, 1); } } if (cy - 1 >= min_x && myMind.obstacleMap[cx, cy - 1] == null) { updOpen(cx, cy, 0, -1); if (cx + 1 <= max_x && myMind.obstacleMap[cx + 1, cy - 1] == null) { updOpen(cx, cy, 1, -1); } if (cx - 1 >= min_x && myMind.obstacleMap[cx - 1, cy - 1] == null) { updOpen(cx, cy, -1, -1); } } return(buildBackMaps(target)); }
public AliveObject Alive(AliveObject alive) { ReceivedAlive?.Invoke(this, EventArgs.Empty); return(alive); }
public RabbitChannel(SubscribeDelegate handler, AliveObject <IModel> model) { Handler = handler; Model = model; _ = model.Value; }
public virtual void action(AliveObject alive) { }