public AttributeData OnGetAttributeData(string key) { if (_ilrObject != null) { return(_ilrObject.OnGetAttributeData(key)); } return(new AttributeData()); }
public void Activate(GameObject owner, MoveEditor.ProjectileEventInfo projectileEventInfo, OnProjectileDeactivated callback) { _owner = owner.GetMonoILRComponent <DynamicMonoILRObject>(); AttributeData attr = _owner.OnGetAttributeData("GetAnimator"); if (_fxHelper != null) { //_fxHelper.Init(owner); } if (owner != null) { Activate(attr.Animator, projectileEventInfo, callback, false); //owner.ID == 1 ); } else { EB.Debug.LogWarning("Failed to activate projectile!"); } }
// get perfect normalized offset private Vector3 CalculatePerfectNormalizedGroundPlaneOffset(CameraBase playerCamera) { float yawOffset = !IsGameCamera() ? _params.yawOffset : 0f; const float FullCircle = 360f; float baseAngle = GlobalCameraData.Instance.gameCameraAngleDegrees; if (_params != null && _params.useTargetLocalSpace && _targets != null && _targets.Count > 0) { Vector3 targetAngle = _targets[0].transform.eulerAngles; baseAngle = targetAngle.y; if (_params.yawFlipped) { //Combatant combatant_obj = _targets[0].GetComponent<Combatant>(); //if (combatant_obj != null) //{ // if (combatant_obj.IsAttackingRightSide()) // { // yawOffset = -yawOffset; // } //} DynamicMonoILRObject ilObj = _targets[0].GetMonoILRComponent <DynamicMonoILRObject>(false); if (ilObj != null) { AttributeData attr = ilObj.OnGetAttributeData("IsAttackingRightSide"); if (attr.IsAttackingRightSide) { yawOffset = -yawOffset; } } } } float camAngleRad = Mathf.Deg2Rad * ((baseAngle + yawOffset) % FullCircle); return(new Vector3(Mathf.Sin(camAngleRad), 0f, Mathf.Cos(camAngleRad))); }
private void DefaultUpdate() { // don't update if player's frozen //if( _owner != null && _owner.Animator.speed == 0.0f ) //{ //return; //} //_previousPosition = GetCenter(); switch (_state) { case ProjectileState.kSpwaned: _state = ProjectileState.kActive; break; case ProjectileState.kActive: { AttributeData attr = _owner.OnGetAttributeData("GetTargetPosition"); Vector3 dir = _owner != null ? attr.TargetPosition - GetCenter() : Vector3.right; //dir.y = 0.0f;//set y to zero to calculate motion on xoz plane. Vector3 displacement = dir * _speed * Time.deltaTime; Vector3 pos = transform.position; pos += displacement; //caculate motion on y float offset_y = _motionCurve.Evaluate(System.Math.Min(Time.realtimeSinceStartup - _startTime / _duration, 1.0f)); pos.y += offset_y; Quaternion rotation = Quaternion.LookRotation(pos - transform.position); transform.rotation = rotation; transform.position = pos; if (_owner != null) { //float prevPosX = _previousPosition.x; //float currPosX = GetCenter().x; //float minPosX = Mathf.Min(prevPosX, currPosX); //float maxPosX = Mathf.Max(prevPosX, currPosX); float distance = Vector3.Distance(GetCenter(), attr.TargetPosition); if (distance < 0.05f) { OnHit(); break; } } // TODO: is it safe to assume that projectiles will never hit walls - since it'll always hit a player first? break; } case ProjectileState.kReturn: { if (UpdateReturn()) { Deactivate(); } break; } default: break; } }