Beispiel #1
0
        public static void BlockView(this IBlockable ib)
        {
            if (ib is RTC_ConnectionStatus_Form)
            {
                return;
            }

            if (ib.blockPanel == null)
            {
                ib.blockPanel = new Panel();
            }

            if (ib is Control c)
            {
                c.Controls.Add(ib.blockPanel);
                ib.blockPanel.Location = new Point(0, 0);
                ib.blockPanel.Size     = c.Size;
                ib.blockPanel.BringToFront();

                var bmp = c.getFormScreenShot();
                bmp.Tint(Color.FromArgb(0xCC, UICore.Dark4Color));

                ib.blockPanel.BackgroundImage = bmp;
            }

            ib.blockPanel.Visible = true;
        }
Beispiel #2
0
 protected void DetachBlockable(IBlockable blockable)
 {
     if (blockable != null)
     {
         blockable.OnCompleted -= new NodeEventHandler(BlockableCompleted);
         blockable.Disposed    -= new EventHandler(BlockableDisposed);
     }
 }
    public void Initialize()
    {
        _ShieldConfig = Instantiate(_ShieldConfig);
        _ShieldConfig.Initialize(this.gameObject);
        CurrentShield = _ShieldConfig;

        MyColliderOffset = GetComponent <BoxCollider2D>().offset;
        MyColliderSize   = GetComponent <BoxCollider2D>().size;
    }
Beispiel #4
0
        private void BeforeExecuteCompleted(INode sender, EventParams paramsValue)
        {
            IBlockable blockable = _beforeExecute as IBlockable;

            if (blockable != null)
            {
                blockable.OnCompleted -= new NodeEventHandler(BeforeExecuteCompleted);
            }
            FinishExecute(sender, paramsValue);
        }
Beispiel #5
0
        public static void UnblockView(this IBlockable ib)
        {
            if (ib is RTC_ConnectionStatus_Form)
            {
                return;
            }

            if (ib.blockPanel != null)
            {
                ib.blockPanel.Visible = false;
            }
        }
Beispiel #6
0
    void OnCollisionEnter2D(Collision2D hit)
    {
        IDamageable dmg   = hit.collider.GetComponent <IDamageable>();
        IBlockable  block = hit.collider.GetComponentInParent <IBlockable>();

        if (dmg != null)
        {
            dmg.TakeDamage(damage);
        }
        else if (block != null)
        {
            block.Block();
        }
        Restore();
    }
Beispiel #7
0
        /// <summary>
        /// Executes the given action, hooking the OnCompleted if it is a Blockable action.
        /// </summary>
        /// <param name="action"></param>
        protected void BlockableExecute(IAction action, EventParams paramsValue)
        {
            IBlockable blockable = action as IBlockable;

            if (blockable != null)
            {
                blockable.OnCompleted += new NodeEventHandler(BlockableCompleted);
                blockable.Disposed    += new EventHandler(BlockableDisposed);
            }

            action.Execute(this, paramsValue);

            if (blockable == null)
            {
                DoCompleted(paramsValue);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Returns true if the before execute action is not a Blockable node, meaning that the FinishExecute should be called immediately.
        /// </summary>
        /// <param name="paramsValue"></param>
        /// <returns></returns>
        private bool DoBeforeExecute(INode sender, EventParams paramsValue)
        {
            if (_beforeExecute != null)
            {
                IBlockable blockable = _beforeExecute as IBlockable;
                if (blockable != null)
                {
                    blockable.OnCompleted += new NodeEventHandler(BeforeExecuteCompleted);
                }

                _beforeExecute.Execute(this, paramsValue);

                // return true to indicate the FinishExecute should be called immediately
                // return false to indicate the FinishExecute should be called on the ExecuteCompleted of the BeforeExecute action
                return(blockable == null);
            }

            return(true);
        }
Beispiel #9
0
 //Needs to happen before start to avoid race conditioning
 public void Awake()
 {
     blockable = gameObject.transform.parent.GetComponentInParent <IBlockable>();
 }
 public GraphicsOverlap(IBlockable blockable1, IBlockable blockable2)
 {
     this.blockable1 = blockable1;
     this.blockable2 = blockable2;
     maskTrs         = Instantiate(GameManager.GetSingleton <GraphicsManager>().spriteMaskTrsPrefab);
 }
Beispiel #11
0
 public GraphicsOverlap(IBlockable blockable1, IBlockable blockable2)
 {
     this.blockable1 = blockable1;
     this.blockable2 = blockable2;
     maskTrs         = Instantiate(GraphicsManager.Instance.spriteMaskTrsPrefab);
 }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        if (flaggedToDestroy)
        {
            return;
        }

        Collider2D[] colliders = getOverlapCollidersFunc();

        foreach (Collider2D c in colliders)
        {
            if (!oldOverlappedColliders.Contains(c) && damagedColliders.Contains(c))
            {
                damagedColliders.Remove(c);
            }

            if (!damagedColliders.Contains(c))
            {
                //if (!c.gameObject.activeSelf)
                //    continue;

                IParryable parryable = c.GetComponent <IParryable>();

                if (parryable != null)
                {
                    Vector2 dir = c.transform.position - collider.transform.position;
                    dir.Normalize();

                    parryable.ParryDamage(damage, dir, doesKnockAway, stunTime);

                    //add it to the list of damaged colliders, so it wont get called again
                    damagedColliders.Add(c);

                    if (OnParry != null)
                    {
                        OnParry(-dir);
                    }

                    //skip over damage check
                    break;
                }

                //if we've hit a block box
                IBlockable blockable = c.GetComponent <IBlockable>();

                if (blockable != null)
                {
                    Vector2 dir = c.transform.position - collider.transform.position;
                    dir.Normalize();

                    blockable.BlockDamage(damage, dir, doesKnockAway, stunTime);

                    //add it to the list of damaged colliders, so it wont get called again
                    damagedColliders.Add(c);

                    if (willDestroyOnBlock)
                    {
                        flaggedToDestroy = true;
                    }

                    //skip over damage check
                    break;
                }

                IDamagable damagable = c.GetComponent <IDamagable>();

                if (damagable != null)
                {
                    Vector2 dir = c.transform.position - collider.transform.position;
                    dir.Normalize();

                    damagable.TakeDamage(damage, dir, doesKnockAway, stunTime);
                    damagedColliders.Add(c);
                }
            }
        }

        oldOverlappedColliders = new HashSet <Collider2D>(colliders);

        if (flaggedToDestroy)
        {
            Destroy(gameObject);
        }
    }