示例#1
0
 ///<summary> method should take a list of all objects, </summary>
 public static void IterateAction(List <Base> roomObjects, Type type)
 {
     foreach (var item in roomObjects)
     {
         if (type.ToString() == "IInteractive")
         {
             if (item is IInteractive)
             {
                 IInteractive tmp = item as IInteractive;
                 tmp.Interact();
             }
         }
         if (type.ToString() == "IBreakable")
         {
             if (item is IBreakable)
             {
                 IBreakable temp = item as IBreakable;
                 temp.Break();
             }
         }
         if (type.ToString() == "ICollectable")
         {
             if (item is ICollectable)
             {
                 ICollectable temp = item as ICollectable;
                 temp.Collect();
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// Iterates through a list
 /// </summary>
 /// <param name="roomObjects"></param>
 /// <param name="type"></param>
 public static void IterateAction(List <Base> roomObjects, Type type)
 {
     //if (typeof(IInteractive).IsAssignableFrom(type))
     foreach (var item in roomObjects)
     {
         if (typeof(IInteractive).IsAssignableFrom(type))
         {
             //dynamic changedObj = Convert.ChangeType(item, type);
             try
             {
                 IInteractive changedObj = (IInteractive)item;
                 changedObj.Interact();
             }
             catch {}
         }
         if (typeof(IBreakable).IsAssignableFrom(type))
         {
             try
             {
                 IBreakable changedObj = (IBreakable)item;
                 changedObj.Break();
             }
             catch {}
         }
         if (typeof(ICollectable).IsAssignableFrom(type))
         {
             try
             {
                 ICollectable changedObj = (ICollectable)item;
                 changedObj.Collect();
             }
             catch {}
         }
     }
 }
        public void Break()
        {
            BeforeStatement();

            bool useLeave = false;

            foreach (Block blk in blocks)
            {
                ExceptionBlock xb = blk as ExceptionBlock;

                if (xb != null)
                {
                    if (xb.IsFinally)
                    {
                        throw new InvalidOperationException(Properties.Messages.ErrInvalidFinallyBranch);
                    }

                    useLeave = true;
                }

                IBreakable brkBlock = blk as IBreakable;

                if (brkBlock != null)
                {
                    il.Emit(useLeave ? OpCodes.Leave : OpCodes.Br, brkBlock.GetBreakTarget());
                    reachable = false;
                    return;
                }
            }

            throw new InvalidOperationException(Properties.Messages.ErrInvalidBreak);
        }
示例#4
0
 ///<summary>This method allows iteraction with the methods within the objects.</summary>
 public static void IterateAction(List <Base> roomObjects, Type type)
 {
     foreach (var element in roomObjects)
     {
         if (type.ToString() == "IInteractive")
         {
             if (element is IInteractive)
             {
                 IInteractive tmp = element as IInteractive;
                 tmp.Interact();
             }
         }
         else if (type.ToString() == "IBreakable")
         {
             if (element is IBreakable)
             {
                 IBreakable tmp = element as IBreakable;
                 tmp.Break();
             }
         }
         else if (type.ToString() == "ICollectable")
         {
             if (element is ICollectable)
             {
                 ICollectable tmp = element as ICollectable;
                 tmp.Collect();
             }
         }
     }
 }
示例#5
0
        public void Break()
        {
            BeforeStatement();

            bool useLeave = false;

            foreach (Block blk in blocks)
            {
                ExceptionBlock xb = blk as ExceptionBlock;

                if (xb != null)
                {
                    if (xb.IsFinally)
                    {
                        throw new InvalidOperationException("Cannot transfer control out of a finally handler");
                    }

                    useLeave = true;
                }

                IBreakable brkBlock = blk as IBreakable;

                if (brkBlock != null)
                {
                    il.Emit(useLeave ? OpCodes.Leave : OpCodes.Br, brkBlock.GetBreakTarget());
                    reachable = false;
                    return;
                }
            }

            throw new InvalidOperationException("Break() called outside of a loop or switch");
        }
示例#6
0
        public IEnumerable <SymbolStatus> SymbolStatusesBreakableReverseOrdered(IBreakable breakable)
        {
            IEnumerable <SymbolStatus> SymbolStatusesBreakable(IBreakable breakable)
            {
                foreach (var stat in mSymbolStatus.Values.Where(v => v.Owned))
                {
                    yield return(stat);
                }

                if (Breakable == breakable)
                {
                    yield break;
                }

                if (Parent != null)
                {
                    foreach (var stat in Parent.SymbolStatusesBreakableReverseOrdered(breakable))
                    {
                        yield return(stat);
                    }
                }
            }

            return(SymbolStatusesBreakable(breakable).OrderByDescending(s => s.order));
        }
示例#7
0
    protected override void OnHitWall(Collision2D collision, Vector2 point)
    {
        //base.OnHitWall();

        switch (state)
        {
        default:
            if (patroller.enabled)
            {
                patroller.SetFacingRight(point.x < 0);
            }
            break;

        case State.Rolling:
            if (collision.gameObject.layer == LayerMask.NameToLayer("Ground"))
            {
                IBreakable breakableBlock = collision.transform.GetComponent <IBreakable>();
                if (breakableBlock != null)
                {
                    breakableBlock.TakeDamage(999);
                }
                controller.Die();
            }
            break;
        }
    }
示例#8
0
        public void AwaitOnCompleted <TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
            where TAwaiter : INotifyCompletion
            where TStateMachine : IAsyncStateMachine
        {
            switch (awaiter)
            {
            case IBreakable breakableAwaiter:
                _inner = breakableAwaiter;
                awaiter.OnCompleted(_continuation);
                break;

            case SelfScopeAwaiter selfScopeAwaiter:
                selfScopeAwaiter.Value = Task.Scope;
                awaiter.OnCompleted(_continuation);
                break;

            case SelfDisposeAwaiter selfDisposeAwaiter:
                selfDisposeAwaiter.Value = Task._Dispose;
                awaiter.OnCompleted(_continuation);
                break;

            default:
                Asr.Fail("passed unbreakable awaiter");
                break;
            }
        }
    /// <summary>
    /// execute methods depending on what interface that item implements
    /// </summary>
    /// <param name="roomObjects">list of objects</param>
    /// <param name="type">types</param>
    public static void IterateAction(List <Base> roomObjects, Type type)
    {
        foreach (var obj in roomObjects)
        {
            switch (type.ToString())
            {
            case "IInteractive":
                if (obj is IInteractive)
                {
                    IInteractive instance = (IInteractive)obj;
                    instance.Interact();
                }
                break;

            case "IBreakable":
                if (obj is IBreakable)
                {
                    IBreakable instance = (IBreakable)obj;
                    instance.Break();
                }
                break;

            case "ICollectable":
                if (obj is ICollectable)
                {
                    ICollectable instance = (ICollectable)obj;
                    instance.Collect();
                }
                break;

            default:
                break;
            }
        }
    }
/// <summary>
/// IterateAction
/// </summary>
/// <param name="roomObjects"></param>
/// <param name="type"></param>
    public static void IterateAction(List <Base> roomObjects, Type type)
    {
        foreach (var cls in roomObjects)
        {
            if (type == typeof(IInteractive))
            {
                if (cls is IInteractive)
                {
                    IInteractive classou = (IInteractive)cls;
                    classou.Interact();
                }
            }
            else if (type == typeof(IBreakable))
            {
                if (cls is IBreakable)
                {
                    IBreakable classou = (IBreakable)cls;
                    classou.Break();
                }
            }
            else if (type == typeof(ICollectable))
            {
                if (cls is ICollectable)
                {
                    ICollectable classou = (ICollectable)cls;
                    classou.Collect();
                }
            }
        }
    }
 public void ReleaseHavoc()
 {
     for (int b = 1; b <= numberOffBadBoys; b++)
     {
         foreach (ChristmasDecoration christmasDecoration in christmasDecorations)
         {
             if (christmasDecoration is IBreakable)
             {
                 IBreakable breakable = (IBreakable)christmasDecoration;
                 breakable.TryToBreak();
             }
             if (christmasDecoration is IEatable)
             {
                 IEatable eatable = (IEatable)christmasDecoration;
                 eatable.TryToEat();
             }
         }
     }
     for (int c = 1; c <= numberOffCats; c++)
     {
         foreach (ChristmasDecoration christmasDecoration in christmasDecorations)
         {
             if (christmasDecoration is ChristmasBauble)
             {
                 ChristmasBauble christmasBauble = (ChristmasBauble)christmasDecoration;
                 christmasBauble.TryToBreak();
             }
             if (christmasDecoration is ChristmasCookie)
             {
                 ChristmasCookie christmasCookie = (ChristmasCookie)christmasDecoration;
                 christmasCookie.TryToEat();
             }
         }
     }
 }
    public static void IterateAction(List <Base> roomObjects, Type type)
    {
        foreach (var element in roomObjects)
        {
            if (type == typeof(IInteractive))
            {
                IInteractive inter = element as IInteractive;
                if (inter != null)
                {
                    inter.Interact();
                }
            }

            if (type == typeof(ICollectable))
            {
                ICollectable inter = element as ICollectable;
                if (inter != null)
                {
                    inter.Collect();
                }
            }

            if (type == typeof(IBreakable))
            {
                IBreakable inter = element as IBreakable;
                if (inter != null)
                {
                    inter.Break();
                }
            }
        }
    }
 public static void IterateAction(List <Base> objects, Type interfaceType)
 {
     foreach (var obj in objects)
     {
         if (interfaceType == typeof(IInteractive))
         {
             IInteractive ghostObject = obj as IInteractive;
             if (ghostObject != null)
             {
                 ghostObject.Interact();
             }
         }
         else if (interfaceType == typeof(IBreakable))
         {
             IBreakable ghostObject = obj as IBreakable;
             if (ghostObject != null)
             {
                 ghostObject.Break();
             }
         }
         else if (interfaceType == typeof(ICollectable))
         {
             ICollectable ghostObject = obj as ICollectable;
             if (ghostObject != null)
             {
                 ghostObject.Collect();
             }
         }
     }
 }
示例#14
0
    private void Awake()
    {
        m_Parent     = GetComponentInParent <IBreakable>();
        m_Collider2D = GetComponent <Collider2D>();
        Player m_PlayerComponent = GetComponentInParent <Player>();

        m_IsPlayer = m_PlayerComponent ? true : false;
    }
示例#15
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     IBreakable breakable = (value as ILoot).Item as IBreakable;
     float percent = breakable.CurrentDurability * 100 / breakable.Durability;
     if (percent >= 66) return "Green";
     else if (percent >= 33) return "Yellow";
     else return "Red";
 }
示例#16
0
 private void OnCollisionEnter(Collision other)
 {
     iBreakable = other.gameObject.GetComponent <IBreakable>();
     if (!isLocked)
     {
         iBreakable?.Break();
     }
 }
示例#17
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        IBreakable component = collision.GetComponent <IBreakable>();

        if (component != null)
        {
            component.Break(1);
        }
    }
示例#18
0
        void BreakCurrent()
        {
            var i = _inner;

            if (i == null)
            {
                return;
            }

            _inner = null;
            i.Unsubscribe();
            i.BreakInner();
        }
示例#19
0
 protected override void OnHitGround(Collision2D collision)
 {
     if (state == State.Rolling)
     {
         IBreakable breakableBlock = collision.gameObject.GetComponent <IBreakable>();
         if (breakableBlock != null)
         {
             breakableBlock.TakeDamage(999);
             controller.Die();
         }
         else if (!bouncerMovement.CountBounce())
         {
             controller.Die();
         }
     }
 }
示例#20
0
 protected void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("NightmatrixBorder"))
     {
         Vanish();
     }
     else if (collision.gameObject.layer == LayerMask.NameToLayer("Ground"))
     {
         IBreakable breakable = collision.GetComponent <IBreakable>();
         if (breakable != null)
         {
             breakable.TakeDamage(m_hitbox.damage);
         }
         Vanish();
     }
 }
示例#21
0
    private void OnCollisionEnter(Collision collision)
    {
        IBreakable breakable = collision.gameObject.GetComponent <IBreakable>();

        if (breakable != null)
        {
            breakable.BreakObject();
        }

        IActivation activationObject = collision.gameObject.GetComponent <IActivation>();

        if (activationObject != null)
        {
            activationObject.DoActivate();
        }
    }
示例#22
0
 override protected void BreakAppliance()
 {
     if (canDestroy && target)
     {
         canDestroy = false;
         float      dmg       = Random.Range(minDamage, maxDamage);
         IBreakable appliance = target.GetComponent <IBreakable>();
         if (appliance != null)
         {
             appliance.Damage(dmg, this);
         }
     }
     else if (!target)
     {
         ObjectIsBroken();
     }
 }
示例#23
0
        /// <summary>
        /// Queue grouped up blocks
        /// Remove all blocks in from from pending blocks
        /// Destroy all adjacent blocks that are the same color to the group
        /// </summary>
        /// <param name="block"></param>
        /// <param name="dir"></param>
        private void QueueGroup(Block block, Direction dir)
        {
            Group      group     = block.GetGroup();
            IBreakable breakable = group.breakable;

            if (group != null && !breakableList.Contains(breakable))
            {
                breakableList.Add(breakable);
                for (int i = 0; i < group.blocks.Count; i++)
                {
                    if (!pendingBlocks.Contains(group.blocks[i]))
                    {
                        pendingBlocks.Add(group.blocks[i]);

                        QueueAdjacentBlocks(group.blocks[i], dir);
                    }
                }
            }
        }
示例#24
0
    protected override void OnWallEvent(Collision2D collision)
    {
        base.OnWallEvent(collision);

        switch (state)
        {
        case State.Idle:
            shooterMovement.NotifyGround();
            break;

        case State.Launched:
            IBreakable breakableBlock = collision.gameObject.GetComponent <IBreakable>();
            if (breakableBlock != null)
            {
                breakableBlock.TakeDamage(999);
            }
            controller.Die();
            break;
        }
    }
    /// <summary>
    ///  Method that will perform primary action on set of given object and
    /// type.
    /// </summary>
    /// <param name="roomObjects"> List of objects to perform actions on
    /// </param>
    /// <param name="type">Interface action to invoke</param>
    public static void IterateAction(List <Base> roomObjects, Type type)
    {
        switch (type.Name)
        {
        case "IInteractive":
            foreach (var i in roomObjects)
            {
                if (i is IInteractive)
                {
                    IInteractive item = i as IInteractive;
                    item.Interact();
                }
            }

            break;

        case "IBreakable":
            foreach (var i in roomObjects)
            {
                if (i is IBreakable)
                {
                    IBreakable item = i as IBreakable;
                    item.Break();
                }
            }

            break;

        case "ICollectable":
            foreach (var i in roomObjects)
            {
                if (i is ICollectable)
                {
                    ICollectable item = i as ICollectable;
                    item.Collect();
                }
            }

            break;
        }
    }
示例#26
0
 public static void IterateAction(List <Base> roomObjects, Type type)
 {
     foreach (Base roomObject in roomObjects)
     {
         if (type == typeof(IInteractive) && roomObject is IInteractive)
         {
             IInteractive iObj = roomObject as IInteractive;
             iObj.Interact();
         }
         if (type == typeof(IBreakable) && roomObject is IBreakable)
         {
             IBreakable iObj = roomObject as IBreakable;
             iObj.Break();
         }
         if (type == typeof(ICollectable) && roomObject is ICollectable)
         {
             ICollectable iObj = roomObject as ICollectable;
             iObj.Collect();
         }
     }
 }
示例#27
0
    protected override void OnHitWall(Collision2D collision, Vector2 point)
    {
        switch (state)
        {
        case State.Idle:
            leaper.SetFacingSide(point.x < 0);
            break;

        case State.Rolling:
            IBreakable breakableBlock = collision.gameObject.GetComponent <IBreakable>();
            if (breakableBlock != null)
            {
                breakableBlock.TakeDamage(999);
                controller.Die();
            }
            else if (!bouncerMovement.CountBounce())
            {
                controller.Die();
            }
            break;
        }
    }
    /// <summary>This method takes a list of all objects, iterate through it, and execute methods</summary>
    public static void IterateAction(List <Base> roomObjects, Type type)
    {
        foreach (var item in roomObjects)
        {
            if (type.ToString() == "IInteractive" && item is IInteractive)
            {
                // Create a Object temporal to execute methods
                IInteractive obj = item as IInteractive;
                // check if the conversion is successful.
                if (obj != null)
                {
                    obj.Interact();
                }
            }

            if (type.ToString() == "IBreakable" && item is IBreakable)
            {
                // Create a Object temporal to execute methods
                IBreakable obj = item as IBreakable;
                // check if the conversion is successful.
                if (obj != null)
                {
                    obj.Break();
                }
            }

            if (type.ToString() == "ICollectable" && item is ICollectable)
            {
                // Create a Object temporal to execute methods
                ICollectable obj = item as ICollectable;
                // check if the conversion is successful
                if (obj != null)
                {
                    obj.Collect();
                }
            }
        }
    }
示例#29
0
        /// <summary>
        /// Add block for pending break, then check adjacent blocks for same color
        /// </summary>
        /// <param name="block"></param>
        public void QueueBlock(Block block, Direction dir)
        {
            IBreakable breakable = block.breakable;

            //Queue original block
            if (QueueBlockToBreak(block))
            {
                //Break adjacent blocks
                switch (dir)
                {
                case Direction.up:
                    QueueAdjacentBlocks(block, Direction.up);
                    break;

                case Direction.right:
                    QueueAdjacentBlocks(block, Direction.right);
                    break;

                case Direction.down:
                    QueueAdjacentBlocks(block, Direction.down);
                    break;

                case Direction.left:
                    QueueAdjacentBlocks(block, Direction.left);
                    break;

                case Direction.all:
                    QueueAdjacentBlocks(block, Direction.all);
                    break;

                case Direction.none:
                default:

                    break;
                }
            }
        }
示例#30
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (state == State.Attacking || state == State.Diving)
        {
            int layer = collision.gameObject.layer;
            if (groundLayer == (groundLayer | 1 << layer))
            {
                hitbox.GetComponent <Collider2D>().enabled = false;
                if (gameObject.activeSelf)
                {
                    StartCoroutine(BounceOnHit());
                }
                m_animator.SetTrigger("Dizzy");

                if (collision.gameObject.layer == LayerMask.NameToLayer("Ground"))
                {
                    IBreakable breakableBlock = collision.transform.GetComponent <IBreakable>();
                    if (breakableBlock != null)
                    {
                        breakableBlock.TakeDamage(999);
                    }
                }

                stompSFX.Play();
                dizzySFX.PlayDelayed(.2f);
                flightFX.Stop();

                transform.rotation = Quaternion.Euler(Vector3.zero);
                m_renderer.flipY   = m_renderer.flipX = false;

                state = State.Dizzy;

                StartCoroutine(DeathTimer());
            }
        }
    }