/// <summary>
 ///  Обработка события "произошла атака"
 /// </summary>
 protected void HandleAttackProcess(object sender, HitEventArgs e)
 {
     if (e.HPDif < 0f)
     {
         Health = Mathf.Clamp(health + healthDrain, 0f, maxHealth);
     }
 }
        private void owner_MouseMovePicked(object sender, HitEventArgs e)
        {
            if (e.MouseEvent.Button == MouseButtons.None)
            {
                HitRecord    hitRecord = e.HitRecord;
                TimelinePath hitPath   = hitRecord.HitPath;

                switch (hitRecord.Type)
                {
                case HitType.IntervalResizeLeft:
                case HitType.IntervalResizeRight:
                    if (Owner.IsEditable(hitPath))
                    {
                        Owner.Cursor = Cursors.SizeWE;
                    }
                    break;

                //one of the scale manipulator's handles?
                case HitType.Custom:
                    if (hitRecord.HitObject == m_leftHitObject ||
                        hitRecord.HitObject == m_rightHitObject)
                    {
                        Owner.Cursor = Cursors.SizeWE;
                    }
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Reflects the argument Laser beam and emits a new Laser beam that
        /// passes through.
        /// </summary>
        /// <param name="sender">The sender of the event, ignored here.</param>
        /// <param name="args">The EventArgs object that describes the event.</param>
        public void OnLaserHit(object sender, HitEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (!args.IsValid)
            {
                throw new ArgumentException("The supplied HitEventArgs object is invalid.");
            }

            // Create a new ray coming out of the other side with the same direction
            // as the original ray. Forward needs to be negative, see LaserEmitter.
            var passThroughEmitter = this.PassThroughEmitter.GetEmitter(args.Laser);

            passThroughEmitter.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            this.Hit = true;

            passThroughEmitter.transform.position = args.Point + (args.Laser.Direction * 0.1f);
            passThroughEmitter.transform.forward  = -args.Laser.Direction;
            LaserProperties propertiesPre  = args.Laser.Emitter.GetComponent <LaserProperties>();
            LaserProperties propertiesPost = passThroughEmitter.GetComponent <LaserProperties>();

            propertiesPost.RGBStrengths = propertiesPre.RGBStrengths;
        }
        private void owner_MouseDownPicked(object sender, HitEventArgs e)
        {
            if (e.MouseEvent.Button != MouseButtons.Left)
            {
                return;
            }

            TimelinePath hitPath = e.HitRecord.HitPath;

            bool isResizing = false;

            switch (e.HitRecord.Type)
            {
            case HitType.IntervalResizeLeft:
                if (Owner.IsEditable(hitPath) && (
                        Owner.Selection.SelectionContains(hitPath) ||
                        Owner.Select <IEvent>(hitPath)))
                {
                    IInterval hitInterval = e.HitRecord.HitTimelineObject as IInterval;
                    m_resizer  = new Resizer(Side.Left, ScaleMode.InPlace, hitInterval.Start, Owner);
                    isResizing = true;
                }
                break;

            case HitType.IntervalResizeRight:
                if (Owner.IsEditable(hitPath) && (
                        Owner.Selection.SelectionContains(hitPath) ||
                        Owner.Select <IEvent>(hitPath)))
                {
                    IInterval hitInterval = e.HitRecord.HitTimelineObject as IInterval;
                    m_resizer  = new Resizer(Side.Right, ScaleMode.InPlace, hitInterval.Start + hitInterval.Length, Owner);
                    isResizing = true;
                }
                break;

            case HitType.Custom:
            {
                HitRecordObject hitManipulator = e.HitRecord.HitObject as HitRecordObject;
                if (hitManipulator != null)
                {
                    if (hitManipulator.Side == Side.Left)
                    {
                        m_resizer = new Resizer(Side.Left, ScaleMode.TimePeriod, m_worldMin, Owner);
                    }
                    else
                    {
                        m_resizer = new Resizer(Side.Right, ScaleMode.TimePeriod, m_worldMax, Owner);
                    }
                    isResizing = true;
                }
            }
            break;

            default:
                m_resizer = null;
                break;
            }

            Owner.IsResizingSelection = isResizing; //legacy. obsolete.
        }
Beispiel #5
0
    protected override void HitHandler(List<object> senders, HitEventArgs args)
    {
        // end attacks
        attackManager.Cancel();

        base.HitHandler(senders, args);
    }
 void DetectFaceNormal(object o, HitEventArgs e)
 {
     if (e.distance <= minDistance)
     {
         return;
     }
     Debug.Log("Detect Face");
     rigidBody.MovePosition(transform.position + e.direction.normalized * Time.deltaTime * speed);
 }
Beispiel #7
0
    /// <summary>
    /// Событие, вызываемое при совершении атаки
    /// </summary>
    public void OnAttack(HitEventArgs e)
    {
        EventHandler <HitEventArgs> handler = AttackEventHandler;

        if (handler != null)
        {
            handler(this, e);
        }
    }
Beispiel #8
0
        /// <summary>
        /// Reflects the argument Laser beam and creates a new Laser beam
        /// in the reflected direction.
        /// </summary>
        /// <param name="sender">The sender of the event, ignored here.</param>
        /// <param name="args">The EventArgs object that describes the event.</param>
        public void OnLaserHit(object sender, HitEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            CreateReflection(args.Laser, args.Normal);
        }
        private void owner_MouseMovePicked(object sender, HitEventArgs e)
        {
            string toolTipText = null;

            if (m_active)
            {
                e.Handled = true;

                if (e.HitRecord.Type == HitType.Interval &&
                    e.MouseEvent.Button == MouseButtons.None &&
                    !m_owner.IsUsingMouse &&
                    m_owner.IsEditable(e.HitRecord.HitPath))
                {
                    SetCursor();
                    TimelinePath hitPath   = e.HitRecord.HitPath;
                    IInterval    hitObject = (IInterval)e.HitRecord.HitTimelineObject;
                    float        worldX    = GdiUtil.InverseTransform(m_owner.Transform, e.MouseEvent.Location.X);

                    //Make sure the snap-to indicator line is drawn.
                    float delta = m_owner.GetSnapOffset(new[] { worldX }, s_snapOptions);

                    worldX += delta;
                    worldX  = m_owner.ConstrainFrameOffset(worldX);

                    using (Matrix localToWorld = D2dTimelineControl.CalculateLocalToWorld(hitPath))
                    {
                        if (worldX <= GdiUtil.Transform(localToWorld, hitObject.Start) ||
                            worldX >= GdiUtil.Transform(localToWorld, hitObject.Start + hitObject.Length))
                        {
                            // Clear the results since a split is impossible.
                            m_owner.GetSnapOffset(new float[] {}, s_snapOptions);
                        }
                        else
                        {
                            toolTipText = worldX.ToString();
                        }
                    }
                }
            }

            if (toolTipText != null)
            {
                m_toolTip.Show(toolTipText, m_owner, e.MouseEvent.Location);
            }
            else
            {
                m_toolTip.Hide(m_owner);
            }
        }
Beispiel #10
0
    /// <summary>
    /// Triggered by HitEvent. Creates and shoots money.
    /// </summary>
    private void HitHandler(object sender, HitEventArgs args)
    {
        if (args.health == 0)
        {
            int amount = random ? Random.Range(minAmount, maxAmount) : minAmount;

            while (amount > 0)
            {
                var money = GameResources.Instance.Money_Pool.nextFree;
                money.transform.position = myTransform.position + Vector3.up;
                money.rigidbody.velocity = new Vector3(Random.Range(-force.x, force.x), Random.Range(0f, force.y), 0f);
                money.rigidbody.angularVelocity = new Vector3(Random.Range(-rotation, rotation), Random.Range(-rotation, rotation), Random.Range(-rotation, rotation));
                amount--;
            }
        }
    }
Beispiel #11
0
    protected override void HitHandler(List<object> senders, HitEventArgs args)
    {
        if (args.health == 0)
        {
            foreach (var player in senders)
            {
                ((Player)player).RecieveKill(enemyType, experience);
            }

            SetState(DyingState, new Dictionary<string, object>());
        }
        else
        {
            currentTarget = ((Character)senders[0]).transform;
            SetState(FlinchingState, new Dictionary<string, object> { { "knockBack", args.hitInfo.knockBack } });
        }
    }
Beispiel #12
0
        private void owner_MouseMovePicked(object sender, HitEventArgs e)
        {
            string toolTipText = null;

            if (m_active)
            {
                e.Handled = true;

                if (e.HitRecord.Type == HitType.Interval &&
                    e.MouseEvent.Button == MouseButtons.None &&
                    !m_owner.IsUsingMouse &&
                    m_owner.IsEditable(e.HitRecord.HitPath))
                {
                    SetCursor();
                    TimelinePath hitPath = e.HitRecord.HitPath;
                    IInterval hitObject = (IInterval)e.HitRecord.HitTimelineObject;
                    float worldX = GdiUtil.InverseTransform(m_owner.Transform, e.MouseEvent.Location.X);

                    //Make sure the snap-to indicator line is drawn.
                    float delta = m_owner.GetSnapOffset(new[] { worldX }, s_snapOptions);

                    worldX += delta;
                    worldX = m_owner.ConstrainFrameOffset(worldX);

                    using (Matrix localToWorld = D2dTimelineControl.CalculateLocalToWorld(hitPath))
                    {
                        if (worldX <= GdiUtil.Transform(localToWorld, hitObject.Start) ||
                            worldX >= GdiUtil.Transform(localToWorld, hitObject.Start + hitObject.Length))
                        {
                            // Clear the results since a split is impossible.
                            m_owner.GetSnapOffset(new float[] {}, s_snapOptions);
                        }
                        else
                        {
                            toolTipText = worldX.ToString();
                        }
                    }
                }
            }

            if (toolTipText != null)
                m_toolTip.Show(toolTipText, m_owner, e.MouseEvent.Location);
            else
                m_toolTip.Hide(m_owner);
        }
        private void owner_Picking(object sender, HitEventArgs e)
        {
            if (m_visibleManipulator)
            {
                Rectangle clipRectangle = Owner.VisibleClientRectangle;

                if (m_leftHandle.IntersectsWith(clipRectangle) &&
                    e.PickRectangle.IntersectsWith(m_leftHandle))
                {
                    e.HitRecord = new HitRecord(HitType.Custom, m_leftHitObject);
                }
                else if (m_rightHandle.IntersectsWith(clipRectangle) &&
                         e.PickRectangle.IntersectsWith(m_rightHandle))
                {
                    e.HitRecord = new HitRecord(HitType.Custom, m_rightHitObject);
                }
            }
        }
    private void OnTriggerEnter(Collider other)
    {
        bool isTeam = false;

        if (owner != null)
        {
            isTeam = other.transform.CompareTag(owner.tag);
        }

        DamageAbleObject healthContainer = other.gameObject.GetComponent <DamageAbleObject>();

        if (healthContainer != null)
        {
            float distance = Vector3.Distance(other.transform.position, transform.position);

            float rangeDamage = damage;
            if (UseDamageReduction)
            {
                rangeDamage = (damageReduction - (distance / radius)) * damage;
                if (rangeDamage <= 0)
                {
                    return;
                }
            }

            if (isTeam)
            {
                rangeDamage *= teamDamageMultiplicator;
            }

            HitEventArgs hitArgs = new HitEventArgs(rangeDamage, owner, other.gameObject, isTeam, true);
            if (OnHit != null)
            {
                OnHit(this, hitArgs);
            }

            if (!hitArgs.Cancel && hitArgs.FinalDamage > 0)
            {
                healthContainer.DoDamage(owner, rangeDamage, StatusEffect);
            }

            exploded = true;
        }
    }
        /// <summary>
        /// Event handler for the timeline control.MouseDownPicked event</summary>
        /// <param name="sender">Timeline control that we are attached to</param>
        /// <param name="e">Event args</param>
        protected virtual void Owner_MouseDownPicked(object sender, HitEventArgs e)
        {
            HitRecord hitRecord = e.HitRecord;
            TimelinePath hitObject = hitRecord.HitPath;
            if (hitObject != null)
            {
                Keys modifiers = Control.ModifierKeys;

                if (e.MouseEvent.Button == MouseButtons.Left)
                {
                    if (modifiers == Keys.None && SelectionContext != null &&
                        SelectionContext.SelectionContains(hitObject))
                    {
                        // The hit object is already selected. Wait until the mouse up to see if there was
                        //  a drag or not. If no drag, then set the selection set to be this one object.
                        m_mouseDownHitRecord = hitRecord;
                        m_mouseDownPos = e.MouseEvent.Location;
                    }
                    else if (modifiers == Keys.Control)
                    {
                        // Either this object is not already selected or Shift key is being held down.
                        //  to be consistent with the Windows interface.
                        m_mouseDownHitRecord = hitRecord;
                        m_mouseDownPos = e.MouseEvent.Location;
                    }
                    else if ((modifiers & Keys.Alt) == 0)
                    {
                        // The 'Alt' key might mean something different. If no Alt key, we can update the
                        //  selection immediately.
                        UpdateSelection(hitRecord, modifiers);
                    }
                }
                else if (e.MouseEvent.Button == MouseButtons.Right)
                {
                    if (modifiers == Keys.None && SelectionContext != null &&
                        !SelectionContext.SelectionContains(hitObject))
                    {
                        // The hit object is not already selected and a right-click landed on it. Select it.
                        UpdateSelection(hitRecord, modifiers);
                    }
                }
            }
        }
Beispiel #16
0
        private void QuickNetronPanel_HitEvent(object sender, HitEventArgs e)
        {
            switch (e.HitType)
            {
            case EnumHitType.Connection:
                if (this.populator.ContainsEdge((Connection)e.Entity))
                {
                    OnHitEdge((Connection)e.Entity, e.Location);
                }
                break;

            case EnumHitType.Shape:
                if (this.populator.ContainsVertex((Shape)e.Entity))
                {
                    OnHitVertex((Shape)e.Entity, e.Location);
                }
                break;
            }
        }
        private void owner_MouseDownPicked(object sender, HitEventArgs e)
        {
            TimelinePath hitPath     = e.HitRecord.HitPath;
            IInterval    hitInterval = e.HitRecord.HitTimelineObject as IInterval;

            if (m_active &&
                e.MouseEvent.Button == MouseButtons.Left &&
                !m_owner.IsUsingMouse &&
                m_owner.IsEditable(hitPath))
            {
                if (hitInterval != null &&
                    e.HitRecord.Type == HitType.Interval)
                {
                    PointF mouseLocation = e.MouseEvent.Location;
                    float  worldX        =
                        Sce.Atf.GdiUtil.InverseTransform(m_owner.Transform, mouseLocation.X);

                    worldX += m_owner.GetSnapOffset(new[] { worldX }, s_snapOptions);

                    float fraction;
                    using (Matrix localToWorld = D2dTimelineControl.CalculateLocalToWorld(hitPath))
                    {
                        fraction =
                            (worldX - GdiUtil.Transform(localToWorld, hitInterval.Start)) /
                            GdiUtil.TransformVector(localToWorld, hitInterval.Length);
                    }

                    if (m_owner.Selection.SelectionContains(hitInterval))
                    {
                        SplitSelectedIntervals(fraction);
                    }
                    else
                    {
                        SplitUnselectedInterval(hitInterval, fraction);
                    }
                }
                Active    = false;
                e.Handled = true; //don't let subsequent listeners get this event
            }
        }
        private void owner_MouseMovePicked(object sender, HitEventArgs e)
        {
            if (e.MouseEvent.Button == MouseButtons.None &&
                !m_owner.IsUsingMouse)
            {
                HitRecord hitRecord = e.HitRecord;
                if (m_owner.IsEditable(hitRecord.HitPath))
                {
                    switch (hitRecord.Type)
                    {
                        case HitType.Interval:
                        case HitType.Key:
                        case HitType.Marker:
                            m_owner.Cursor = Cursors.SizeAll;
                            break;

                        default:
                            break;
                    }
                }
            }
        }
 private void QuickNetronPanel_HitEvent(object sender, HitEventArgs e)
 {
     switch(e.HitType)
     {
         case EnumHitType.Connection:
             if (this.populator.ContainsEdge((Connection)e.Entity))
                 OnHitEdge((Connection)e.Entity,e.Location);
             break;
         case EnumHitType.Shape:
             if (this.populator.ContainsVertex((Shape)e.Entity))
                 OnHitVertex((Shape)e.Entity,e.Location);
             break;
     }
 }
Beispiel #20
0
 /// <summary>
 /// Start flinching after being hit.
 /// </summary>
 protected virtual void HitHandler(List<object> senders, HitEventArgs args)
 {
     if (args.damage > 0)
     {
         if (args.health > 0)
         {
             SetState(FlinchingState, new Dictionary<string, object> { { "knockBack", args.hitInfo.knockBack } });
         }
         else
         {
             SetState(DyingState, new Dictionary<string, object>());
         }
     }
 }
        private void owner_MouseDownPicked(object sender, HitEventArgs e)
        {
            if (e.MouseEvent.Button == MouseButtons.Left &&
                !m_owner.IsUsingMouse)
            {
                m_mouseMoveHitRecord = null;

                HitRecord hitRecord = e.HitRecord;
                if (m_owner.IsEditable(hitRecord.HitPath))
                {
                    switch (e.HitRecord.Type)
                    {
                        case HitType.GroupMove:
                        case HitType.TrackMove:
                        case HitType.Interval:
                        case HitType.Key:
                        case HitType.Marker:
                            m_mouseMoveHitRecord = hitRecord;
                            break;
                    }
                }

                m_owner.IsMovingSelection = m_mouseMoveHitRecord != null; //obsolete
            }
        }
 private void OnHit(HitEventArgs args)
 {
     if (this.Hit != null)
     {
         this.Hit(this, args);
     }
 }
Beispiel #23
0
 //
 protected void OnGroupHitEvent(List<object> senders, HitEventArgs args)
 {
     if (HitEvent != null)
     {
         HitEvent(senders, args);
     }
 }
Beispiel #24
0
        private void owner_Picking(object sender, HitEventArgs e)
        {
            Rectangle clipRectangle = Owner.VisibleClientRectangle;

            if (m_handleRect.IntersectsWith(clipRectangle) &&
                e.PickRectangle.IntersectsWith(m_handleRect))
            {
                // sets Handled to true
                e.HitRecord = new HitRecord(HitType.Custom, m_handleHitObject);
            }
        }
Beispiel #25
0
 private void owner_MouseMovePicked(object sender, HitEventArgs e)
 {
     if (e.MouseEvent.Button == MouseButtons.None &&
         e.HitRecord.HitObject == m_handleHitObject)
     {
         Owner.Cursor = Cursors.SizeWE;
         e.Handled = true;
     }
 }
Beispiel #26
0
 private void owner_MouseDownPicked(object sender, HitEventArgs e)
 {
     if (e.MouseEvent.Button == MouseButtons.Left &&
         e.HitRecord.HitObject == m_handleHitObject)
     {
         m_isMoving = true;
         Owner.Cursor = Cursors.SizeWE;
         e.Handled = true;
         Owner.Invalidate();
     }
     else if (e.HitRecord.Type == HitType.TimeScale)
     {
         m_isMoving = false;
         Matrix worldToView = Owner.Transform;
         // Setting the position also invalidates the Owner Control.
         PointF mouseLocation = e.MouseEvent.Location;
         Position = GdiUtil.InverseTransform(worldToView, mouseLocation.X);
     }
 }
Beispiel #27
0
    protected override void HitHandler(List<object> senders, HitEventArgs args)
    {
        if (currentState == DefendingState)
        {
            if (perfectShield)
            {
                Log("Perfect Shield!", Debugger.LogTypes.Combat);
            }
            else
            {
                shieldHealth -= args.hitInfo.damage / 10;
                if (shieldHealth < 0)
                {
                    shieldHealth = 0;
                    SetState(StunState, new Dictionary<string, object> { { "stunTime", 2f } }); // need to calculate stun time
                }
            }
            return;
        }

        // end attacks
        attackManager.Cancel();
        comboManager.Cancel();
        // cancel taunt

        base.HitHandler(senders, args);
    }
        private void owner_MouseDownPicked(object sender, HitEventArgs e)
        {
            TimelinePath hitPath = e.HitRecord.HitPath;
            IInterval hitInterval = e.HitRecord.HitTimelineObject as IInterval;

            if (m_active &&
                e.MouseEvent.Button == MouseButtons.Left &&
                !m_owner.IsUsingMouse &&
                m_owner.IsEditable(hitPath))
            {
                if (hitInterval != null &&
                    e.HitRecord.Type == HitType.Interval)
                {
                    PointF mouseLocation = e.MouseEvent.Location;
                    float worldX =
                        Sce.Atf.GdiUtil.InverseTransform(m_owner.Transform, mouseLocation.X);

                    worldX += m_owner.GetSnapOffset(new[] { worldX }, s_snapOptions);

                    Matrix localToWorld = D2dTimelineControl.CalculateLocalToWorld(hitPath);

                    float fraction =
                        (worldX - GdiUtil.Transform(localToWorld, hitInterval.Start)) /
                        GdiUtil.TransformVector(localToWorld, hitInterval.Length);

                    if (m_owner.Selection.SelectionContains(hitInterval))
                        SplitSelectedIntervals(fraction);
                    else
                        SplitUnselectedInterval(hitInterval, fraction);
                }
                Active = false;
                e.Handled = true; //don't let subsequent listeners get this event
            }
        }