// CORE private void Update() { if (entity.isAttached && entity.isOwner) { if (!_totemPosition) { var totem = TotemHelpers.FindTotem(); if (totem) { _totemPosition = totem.transform; _totemOwnership = totem.GetComponent <TotemOwnership>(); } } else { //Arrow stick to the ground this.transform.forward = new Vector3(-(_totemPosition.transform.position.x - this.transform.position.x), 0, -(_totemPosition.transform.position.z - this.transform.position.z)); if (_totemOwnership.IsLocalOwner(state.OwnerID)) { _arrowTotem.enabled = false; } else { _arrowTotem.enabled = true; } } } }
// PRIVATE private void ThrowTotem() { if (_totemOwnership.IsLocalOwner(state.OwnerID) && _totemOwnership.IsSynchronized()) { TotemThrown totemThrownEvent = TotemThrown.Create(); totemThrownEvent.KartEntity = entity; totemThrownEvent.OwnerID = state.OwnerID; totemThrownEvent.ForwardDirection = _throwingDirection.LastDirectionUp != Direction.Backward; // TO DO BETTER totemThrownEvent.Send(); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag(Constants.Tag.ItemBox)) { if (!_totemOwnership) { _totemOwnership = FindObjectOfType <TotemOwnership>(); } if (entity.isAttached && !state.CanPickTotem && !_totemOwnership.IsLocalOwner(state.OwnerID)) { Debug.Log("Recharching kart."); _energyDischarger.FullyCharge(); other.GetComponent <Items.Lottery.ItemBox>().Activate(); } } }