public bool collidesRect(CGameObject aGameObject)
 {
     if (getX() + getLeftOffsetBoundingBox() < aGameObject.getX() + aGameObject.getWidth() - aGameObject.getRightOffsetBoundingBox() &&
         getX() + getWidth() - getRightOffsetBoundingBox() > aGameObject.getX() + aGameObject.getLeftOffsetBoundingBox() &&
         getY() + getTopOffsetBoundingBox() < aGameObject.getY() + aGameObject.getHeight() - aGameObject.getBottomOffsetBoundingBox() &&
         getHeight() + getY() - getBottomOffsetBoundingBox() > aGameObject.getY() + aGameObject.getTopOffsetBoundingBox())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
 public bool collides(CGameObject aGameObject)
 {
     if (CMath.dist(getX(), getY(), aGameObject.getX(), aGameObject.getY()) < (getRadius() + aGameObject.getRadius()))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
 public override void setState(int aState)
 {
     base.setState(aState);
     if (getState() == STATE_WAITING)
     {
         setVisible(false);
     }
     else if (getState() == STATE_ACTING)
     {
         setVisible(true);
         setXY(entityCasting.getX() + posX, entityCasting.getY() + posY);
     }
     else if (getState() == STATE_ENDED)
     {
         setDead(true);
         setVisible(false);
     }
 }
Exemple #4
0
    public hitBox(CGameObject caster, int sizeX, int sizeY, int positionX, int positionY, int frameDelay, int duration, int team, bool recursivo = false, int cantDeRepeticiones = 0)
    {
        entityCasting = caster;
        width         = sizeX;
        height        = sizeY;

        setXY(caster.getX() + positionX, caster.getY() + positionY);

        delay = frameDelay;

        boxDuration = duration;

        if (recursivo)
        {
            boxRecursivo = recursivo;
            repeticiones = cantDeRepeticiones;
        }


        setImage(Resources.Load <Sprite>("Sprites/ui/pixel"));
        setSortingLayerName("Player");
        setSortingOrder(20);
        setColor(Color.blue);
        setAlpha(0.5f);
        setName(caster + " hitBox");

        posX = positionX;
        posY = positionY;
        setXY(-width, -height);


        setScaleX(sizeX);
        setScaleY(sizeY);

        if (delay == 0)
        {
            setState(STATE_ACTING);
        }
        else
        {
            setState(STATE_WAITING);
        }
    }