Exemple #1
0
 public static void Reset()
 {
     Spawner.Reset();
     BlockManager.Clear();
     BlockArea.Reset();
     score = 0;
 }
Exemple #2
0
 public void Lay()
 {
     prevGrabbed = true;
     planting    = true;
     BlockArea.Place(this);
     StartCoroutine("Plant");
 }
    public Vector3 testCollision(BlockArea blockableArea)
    {
        if (isHit)
        {
            return(Vector3.zero);
        }
        foreach (HitBox hitBox in hitBoxes)
        {
            if (hitBox.collisionType == CollisionType.noCollider)
            {
                continue;
            }

            Vector3 blockablePosition = blockableArea.position.position;
            Vector3 hitBoxPosition    = hitBox.position.position;
            if (!detect3dHits)
            {
                blockablePosition = new Vector3(blockableArea.position.position.x, blockableArea.position.position.y, -.5f);
                hitBoxPosition    = new Vector3(hitBox.position.position.x, hitBox.position.position.y, -.5f);
            }
            blockablePosition   += new Vector3(blockableArea.offSet.x * -controlsScript.mirror, blockableArea.offSet.y, 0);
            blockablePosition.x += (blockableArea.radius / 2) * -controlsScript.mirror;
            float dist = Vector3.Distance(blockablePosition, hitBoxPosition);
            if (dist <= blockableArea.radius + hitBox.radius)
            {
                return((blockablePosition + hitBoxPosition) / 2);
            }
        }
        return(Vector3.zero);
    }
    void Start()
    {
        gameObject.AddComponent <SphereCollider>();
        if (opControlsScript.gameObject.name == "Player1")
        {
            gameObject.layer  = LayerMask.NameToLayer("Projectile1");
            opProjectileLayer = LayerMask.NameToLayer("Projectile2");
        }
        else
        {
            gameObject.layer  = LayerMask.NameToLayer("Projectile2");
            opProjectileLayer = LayerMask.NameToLayer("Projectile1");
        }
        opProjectileMask = 1 << opProjectileLayer;

        if (mirror == -1)
        {
            directionVector = Vector3.left;
            directionFloat  = -1;
        }
        totalHits = data.totalHits;
        //Quaternion quaternionAngle = Quaternion.Euler(0, 0, angle) * Vector3(direction, 0, 0);
        //movement = quaternionAngle * speed;
        float angleRad = (data.directionAngle / 180) * Mathf.PI;

        movement = ((Mathf.Sin(angleRad) * Vector3.up) + (Mathf.Cos(angleRad) * directionVector)) * data.speed;
        Destroy(gameObject, data.duration);
        transform.Translate(new Vector3(data.offSet.x * directionFloat, data.offSet.y, data.offSet.z));

        blockableArea          = new BlockArea();
        blockableArea.position = gameObject.transform;
        blockableArea.radius   = data.hitRadius + 3;
    }
Exemple #5
0
    Vector3 SnapColumn(Vector3 position, Quaternion rotation)
    {
        IntegerVector3 transformedDim = rotation * dimensions;

        position.x = BlockArea.SnapDimension(BlockArea.ClampDimension(position.x, transformedDim.x));
        position.z = BlockArea.SnapDimension(BlockArea.ClampDimension(position.z, transformedDim.z));

        return(position);
    }
Exemple #6
0
 public void Unlay()
 {
     if (planting)
     {
         planting = false;
         BlockArea.Unplace(this);
         StopCoroutine("Plant");
     }
 }
Exemple #7
0
    IEnumerator Plant()
    {
        // Debug
        //cubeVFX.ApplyColor(Color.gray);

        yield return(new WaitForSeconds(gs.plantTime));

        // Snap (transform);
        BlockArea.Plant(this);
    }
        public override Map Generate(Map map, BlockArea area)
        {
            for (int x = area.X; x < area.Width; x++)
            {
                for (int y = area.Y; y < area.Height; y++)
                {
                    map.Blocks[x, y] = new Block(map.Types[0]);
                }
            }

            return map;
        }
Exemple #9
0
        public int AddLeader(BlockArea ba, FontState fontState, float red,
                             float green, float blue, int leaderPattern,
                             int leaderLengthMinimum, int leaderLengthOptimum,
                             int leaderLengthMaximum, int ruleThickness,
                             int ruleStyle, int leaderPatternWidth,
                             int leaderAlignment)
        {
            LineArea la = ba.getCurrentLineArea();

            if (la == null)
            {
                return(-1);
            }

            la.changeFont(fontState);
            la.changeColor(red, green, blue);

            if (leaderLengthOptimum <= (la.getRemainingWidth()))
            {
                la.AddLeader(leaderPattern, leaderLengthMinimum,
                             leaderLengthOptimum, leaderLengthMaximum, ruleStyle,
                             ruleThickness, leaderPatternWidth, leaderAlignment);
            }
            else
            {
                la = ba.createNextLineArea();
                if (la == null)
                {
                    return(-1);
                }
                la.changeFont(fontState);
                la.changeColor(red, green, blue);

                if (leaderLengthMinimum <= la.getContentWidth())
                {
                    la.AddLeader(leaderPattern, leaderLengthMinimum,
                                 leaderLengthOptimum, leaderLengthMaximum,
                                 ruleStyle, ruleThickness, leaderPatternWidth,
                                 leaderAlignment);
                }
                else
                {
                    FonetDriver.ActiveDriver.FireFonetWarning(
                        "Leader doesn't fit into line, it will be clipped to fit.");
                    la.AddLeader(leaderPattern, la.getRemainingWidth(),
                                 leaderLengthOptimum, leaderLengthMaximum,
                                 ruleStyle, ruleThickness, leaderPatternWidth,
                                 leaderAlignment);
                }
            }
            return(1);
        }
Exemple #10
0
 public void RenderBlockArea(BlockArea area)
 {
     // KLease: Temporary test to fix block positioning
     // Offset ypos by padding and border widths
     this.currentYPosition -= (area.getPaddingTop()
                               + area.getBorderTopWidth());
     DoFrame(area);
     foreach (Box b in area.getChildren())
     {
         b.render(this);
     }
     this.currentYPosition -= (area.getPaddingBottom()
                               + area.getBorderBottomWidth());
 }
    public Vector3 TestCollision(BlockArea blockableArea)
    {
        HurtBox hurtBox = new HurtBox();

        hurtBox.position      = blockableArea.position;
        hurtBox.shape         = blockableArea.shape;
        hurtBox.rect          = blockableArea.rect;
        hurtBox.followXBounds = blockableArea.followXBounds;
        hurtBox.followYBounds = blockableArea.followYBounds;
        hurtBox.radius        = blockableArea.radius;
        hurtBox.offSet        = blockableArea.offSet;

        // We use throw confirmation type so the engine doesn't register the state of the stroke hitbox as hit
        return(HitBoxesScript.TestCollision(this.hitBoxes, new HurtBox[] { hurtBox }, HitConfirmType.Hit, controlsScript.mirror));
    }
Exemple #12
0
        protected static int addRealText(BlockArea ba, FontState fontState,
                                         float red, float green, float blue,
                                         WrapOption wrapOption, LinkSet ls,
                                         int whiteSpaceCollapse, char[] data,
                                         int start, int end, TextState textState,
                                         VerticalAlign vAlign)
        {
            int ts, te;

            char[] ca;

            ts = start;
            te = end;
            ca = data;

            LineArea la = ba.getCurrentLineArea();

            if (la == null)
            {
                return(start);
            }

            la.changeFont(fontState);
            la.changeColor(red, green, blue);
            la.changeWrapOption(wrapOption);
            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
            la.changeVerticalAlign(vAlign);
            ba.setupLinkSet(ls);

            ts = la.addText(ca, ts, te, ls, textState);

            while (ts != -1)
            {
                la = ba.createNextLineArea();
                if (la == null)
                {
                    return(ts);
                }
                la.changeFont(fontState);
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                ba.setupLinkSet(ls);

                ts = la.addText(ca, ts, te, ls, textState);
            }
            return(-1);
        }
Exemple #13
0
    // Snapping dynamics:

    // snaps the height if necessary
    // @return: did a snap actually occur?
    bool SnapHeight(Transform t)
    {
        IntegerVector3 index = BlockArea.WorldSpaceToIndex(t.position);

        if (BlockArea.IsOccupied(index, cubePositions, t.rotation, id))
        {
            do
            {
                index.y++;
            } while (BlockArea.IsOccupied(index, cubePositions, t.rotation, id));

            t.SetPositionAndRotation(BlockArea.IndexToWorldSpace(index), t.rotation);

            return(true);
        }
        return(false);
    }
Exemple #14
0
    void Update()
    {
        if (grabbed)
        {
            shadow.transform.SetPositionAndRotation(transform.position, transform.rotation);
            Snap(shadow.transform);
        }
        else if (!planting)
        {
            transform.position += BlockManager.BlockFallingSpeed(transform.position.y) * Time.deltaTime * Vector3.down;

            //if (BlockArea.IsOccupied (BlockArea.WorldSpaceToIndex (transform.position), cubePositions, transform.rotation)) {
            //	Snap (transform);
            //	Lay ();
            //}
            if (Snap(transform))
            {
                Lay();
            }
        }
        if (planting)
        {
            IntegerVector3 underIndex = BlockArea.WorldSpaceToIndex(transform.position) + new IntegerVector3(0, -1, 0);

            if (!BlockArea.IsOccupied(underIndex, cubePositions, transform.rotation, id))
            {
                Unlay();
            }
        }

        // Debug

        /*cubeVFX.ApplyColor(Color.blue);
         * if (delayedUngrabbed) {
         *      cubeVFX.ApplyColor(Color.yellow);
         * }
         * if (grabbed) {
         *      cubeVFX.ApplyColor(Color.red);
         * }
         * if (planting) {
         *      cubeVFX.ApplyColor(Color.green);
         * }*/
    }
Exemple #15
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                this.marker = 0;
            }
            BlockArea blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(),
                              startIndent, endIndent, textIndent, align,
                              alignLast, lineHeight);

            blockArea.setGeneratedBy(this);
            blockArea.isFirst(true);
            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.start();

            blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
            blockArea.setIDReferences(area.getIDReferences());

            blockArea.setTableCellXOffset(area.getTableCellXOffset());

            int numChildren = this.children.Count;

            for (int i = this.marker; i < numChildren; i++)
            {
                FONode fo = (FONode)children[i];
                Status status;
                if ((status = fo.Layout(blockArea)).isIncomplete())
                {
                    this.ResetMarker();
                    return(status);
                }
            }
            blockArea.end();
            area.addChild(blockArea);
            area.increaseHeight(blockArea.GetHeight());
            blockArea.isLast(true);
            return(new Status(Status.OK));
        }
Exemple #16
0
    void Start()
    {
        main = this;

        blocks   = new GameObject[gs.areaSize, gs.fullAreaHeight, gs.areaSize];
        occupied = new OccupationState[gs.areaSize, gs.fullAreaHeight, gs.areaSize];

        for (int x = 0; x < gs.areaSize; x++)
        {
            for (int y = 0; y < gs.fullAreaHeight; y++)
            {
                for (int z = 0; z < gs.areaSize; z++)
                {
                    occupied [x, y, z] = new OccupationState();
                }
            }
        }

        heightOffset = gs.floorHeight + gs.blockSize;
        corner       = -(gs.areaSize - 1) * gs.blockSize / 2;
    }
Exemple #17
0
    //private int opProjectileLayer;
    //private int opProjectileMask;

    void Start()
    {
        gameObject.AddComponent <SphereCollider>();

        /*if (opControlsScript.gameObject.name == "Player1"){
         *      gameObject.layer = LayerMask.NameToLayer("Projectile1");
         *      opProjectileLayer = LayerMask.NameToLayer("Projectile2");
         * }else{
         *      gameObject.layer = LayerMask.NameToLayer("Projectile2");
         *      opProjectileLayer = LayerMask.NameToLayer("Projectile1");
         * }
         * opProjectileMask = 1 << opProjectileLayer;*/

        if (mirror == 1)
        {
            directionVector = new Vector3(-1, 0, 0);
        }

        totalHits = data.totalHits;

        float angleRad = ((float)data.directionAngle / 180) * Mathf.PI;

        movement = ((Mathf.Sin(angleRad) * Vector3.up) + (Mathf.Cos(angleRad) * directionVector)) * data.speed;
        UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(this.gameObject); }catch {} }, data.duration);
        transform.Translate(new Vector3(data.castingOffSet.x * -mirror, data.castingOffSet.y, data.castingOffSet.z));

        // Create Blockable Area
        blockableArea = new BlockArea();
        blockableArea = data.blockableArea;

        // Create Hurtbox
        hurtBox = new HurtBox();
        hurtBox = data.hurtBox;

        // Create Hitbox
        hitBox               = new HitBox();
        hitBox.shape         = hurtBox.shape;
        hitBox.rect          = hurtBox.rect;
        hitBox.followXBounds = hurtBox.followXBounds;
        hitBox.followYBounds = hurtBox.followYBounds;
        hitBox.radius        = hurtBox.radius;
        hitBox.offSet        = hurtBox.offSet;
        hitBox.position      = gameObject.transform;

        UpdateRenderer();

        if (data.spaceBetweenHits == Sizes.Small)
        {
            spaceBetweenHits = .15f;
        }
        else if (data.spaceBetweenHits == Sizes.Medium)
        {
            spaceBetweenHits = .2f;
        }
        else if (data.spaceBetweenHits == Sizes.High)
        {
            spaceBetweenHits = .3f;
        }


        // Create Hit data
        hit                             = new Hit();
        hit.hitType                     = data.hitType;
        hit.spaceBetweenHits            = data.spaceBetweenHits;
        hit.hitStrength                 = data.hitStrength;
        hit.hitStunType                 = HitStunType.Frames;
        hit.hitStunOnHit                = data.hitStunOnHit;
        hit.hitStunOnBlock              = data.hitStunOnBlock;
        hit.damageOnHit                 = data.damageOnHit;
        hit.damageOnBlock               = data.damageOnBlock;
        hit.damageScaling               = data.damageScaling;
        hit.damageType                  = data.damageType;
        hit.groundHit                   = data.groundHit;
        hit.airHit                      = data.airHit;
        hit.downHit                     = data.downHit;
        hit.overrideHitEffects          = data.overrideHitEffects;
        hit.hitEffects                  = data.hitEffects;
        hit.resetPreviousHorizontalPush = true;
        hit.pushForce                   = data.pushForce;
        hit.pullEnemyIn                 = new PullIn();
        hit.pullEnemyIn.enemyBodyPart   = BodyPart.none;
    }
Exemple #18
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginProps           mProps    = propMgr.GetMarginProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align      = this.properties.GetTextAlign();
                this.alignLast  = this.properties.GetTextAlignLast();
                this.lineHeight =
                    this.properties.GetProperty("line-height").GetLength().MValue();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();
                this.id = this.properties.GetProperty("id").GetString();

                area.getIDReferences().CreateID(id);

                this.marker = 0;
            }

            if (area is BlockArea)
            {
                area.end();
            }

            if (spaceBefore != 0)
            {
                area.addDisplaySpace(spaceBefore);
            }

            this.blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(), 0, 0,
                              0, align, alignLast, lineHeight);
            this.blockArea.setTableCellXOffset(area.getTableCellXOffset());
            this.blockArea.setGeneratedBy(this);
            this.areasGenerated++;
            if (this.areasGenerated == 1)
            {
                this.blockArea.isFirst(true);
            }
            this.blockArea.addLineagePair(this, this.areasGenerated);

            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.start();

            blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
            blockArea.setIDReferences(area.getIDReferences());

            int numChildren = this.children.Count;

            if (numChildren != 2)
            {
                throw new FonetException("list-item must have exactly two children");
            }
            ListItemLabel label = (ListItemLabel)children[0];
            ListItemBody  body  = (ListItemBody)children[1];

            Status status;

            if (this.marker == 0)
            {
                area.GetMyRefs().ConfigureID(id, area);

                status = label.Layout(blockArea);
                if (status.isIncomplete())
                {
                    return(status);
                }
            }

            status = body.Layout(blockArea);
            if (status.isIncomplete())
            {
                blockArea.end();
                area.addChild(blockArea);
                area.increaseHeight(blockArea.GetHeight());
                this.marker = 1;
                return(status);
            }

            blockArea.end();
            area.addChild(blockArea);
            area.increaseHeight(blockArea.GetHeight());

            if (spaceAfter != 0)
            {
                area.addDisplaySpace(spaceAfter);
            }

            if (area is BlockArea)
            {
                area.start();
            }
            this.blockArea.isLast(true);
            return(new Status(Status.OK));
        }
    public Vector3 TestCollision(BlockArea blockableArea)
    {
        HurtBox hurtBox = new HurtBox();
        hurtBox.position = blockableArea.position;
        hurtBox.shape = blockableArea.shape;
        hurtBox.rect = blockableArea.rect;
        hurtBox.followXBounds = blockableArea.followXBounds;
        hurtBox.followYBounds = blockableArea.followYBounds;
        hurtBox.radius = blockableArea.radius;
        hurtBox.offSet = blockableArea.offSet;

        // We use throw confirmation type so the engine doesn't register the state of the stroke hitbox as hit
        return HitBoxesScript.TestCollision(this.hitBoxes, new HurtBox[]{hurtBox}, HitConfirmType.Hit, controlsScript.mirror);
    }
Exemple #20
0
        public override Status Layout(Area area)
        {
            BlockArea blockArea;

            if (this.marker == MarkerBreakAfter)
            {
                return(new Status(Status.OK));
            }

            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps  = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps  = propMgr.GetAuralProps();
                BorderAndPadding      bap        = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps     = propMgr.GetBackgroundProps();
                HyphenationProps      mHyphProps = propMgr.GetHyphenationProps();
                MarginProps           mProps     = propMgr.GetMarginProps();
                RelativePositionProps mRelProps  = propMgr.GetRelativePositionProps();

                this.align      = this.properties.GetTextAlign();
                this.alignLast  = this.properties.GetTextAlignLast();
                this.breakAfter = this.properties.GetProperty("break-after").GetEnum();
                this.lineHeight =
                    this.properties.GetProperty("line-height").GetLength().MValue();
                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();
                this.textIndent =
                    this.properties.GetProperty("text-indent").GetLength().MValue();
                this.keepWithNext =
                    this.properties.GetProperty("keep-with-next").GetEnum();

                this.blockWidows =
                    this.properties.GetProperty("widows").GetNumber().IntValue();
                this.blockOrphans = (int)
                                    this.properties.GetProperty("orphans").GetNumber().IntValue();
                this.id = this.properties.GetProperty("id").GetString();

                if (area is BlockArea)
                {
                    area.end();
                }

                if (area.getIDReferences() != null)
                {
                    area.getIDReferences().CreateID(id);
                }

                this.marker = 0;

                int breakBeforeStatus = propMgr.CheckBreakBefore(area);
                if (breakBeforeStatus != Status.OK)
                {
                    return(new Status(breakBeforeStatus));
                }

                int numChildren = this.children.Count;
                for (int i = 0; i < numChildren; i++)
                {
                    FONode fo = (FONode)children[i];
                    if (fo is FOText)
                    {
                        if (((FOText)fo).willCreateArea())
                        {
                            fo.SetWidows(blockWidows);
                            break;
                        }
                        else
                        {
                            children.RemoveAt(i);
                            numChildren = this.children.Count;
                            i--;
                        }
                    }
                    else
                    {
                        fo.SetWidows(blockWidows);
                        break;
                    }
                }

                for (int i = numChildren - 1; i >= 0; i--)
                {
                    FONode fo = (FONode)children[i];
                    if (fo is FOText)
                    {
                        if (((FOText)fo).willCreateArea())
                        {
                            fo.SetOrphans(blockOrphans);
                            break;
                        }
                    }
                    else
                    {
                        fo.SetOrphans(blockOrphans);
                        break;
                    }
                }
            }

            if ((spaceBefore != 0) && (this.marker == 0))
            {
                area.addDisplaySpace(spaceBefore);
            }

            if (anythingLaidOut)
            {
                this.textIndent = 0;
            }

            if (marker == 0 && area.getIDReferences() != null)
            {
                MyIDRefs refs = (MyIDRefs)area.getIDReferences();
                refs.ConfigureID(id, area);
            }

            int spaceLeft = area.spaceLeft();

            blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(),
                              startIndent, endIndent, textIndent, align,
                              alignLast, lineHeight);
            blockArea.setGeneratedBy(this);
            this.areasGenerated++;
            if (this.areasGenerated == 1)
            {
                blockArea.isFirst(true);
            }
            blockArea.addLineagePair(this, this.areasGenerated);
            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.setBackground(propMgr.GetBackgroundProps());
            blockArea.setBorderAndPadding(propMgr.GetBorderAndPadding());
            blockArea.setHyphenation(propMgr.GetHyphenationProps());
            blockArea.start();

            blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
            blockArea.setIDReferences(area.getIDReferences());

            blockArea.setTableCellXOffset(area.getTableCellXOffset());

            for (int i = this.marker; i < children.Count; i++)
            {
                FONode fo = (FONode)children[i];
                Status status;
                if ((status = fo.Layout(blockArea)).isIncomplete())
                {
                    this.marker = i;
                    if (status.getCode() == Status.AREA_FULL_NONE)
                    {
                        if ((i != 0))
                        {
                            status = new Status(Status.AREA_FULL_SOME);
                            area.addChild(blockArea);
                            area.setMaxHeight(area.getMaxHeight() - spaceLeft
                                              + blockArea.getMaxHeight());
                            area.increaseHeight(blockArea.GetHeight());
                            anythingLaidOut = true;

                            return(status);
                        }
                        else
                        {
                            anythingLaidOut = false;
                            return(status);
                        }
                    }
                    area.addChild(blockArea);
                    area.setMaxHeight(area.getMaxHeight() - spaceLeft
                                      + blockArea.getMaxHeight());
                    area.increaseHeight(blockArea.GetHeight());
                    anythingLaidOut = true;
                    return(status);
                }
                anythingLaidOut = true;
            }

            blockArea.end();

            area.setMaxHeight(area.getMaxHeight() - spaceLeft
                              + blockArea.getMaxHeight());

            area.addChild(blockArea);

            area.increaseHeight(blockArea.GetHeight());

            if (spaceAfter != 0)
            {
                area.addDisplaySpace(spaceAfter);
            }

            if (area is BlockArea)
            {
                area.start();
            }
            areaHeight   = blockArea.GetHeight();
            contentWidth = blockArea.getContentWidth();
            int breakAfterStatus = propMgr.CheckBreakAfter(area);

            if (breakAfterStatus != Status.OK)
            {
                this.marker = MarkerBreakAfter;
                blockArea   = null;
                return(new Status(breakAfterStatus));
            }

            if (keepWithNext != 0)
            {
                blockArea = null;
                return(new Status(Status.KEEP_WITH_NEXT));
            }

            blockArea.isLast(true);
            blockArea = null;
            return(new Status(Status.OK));
        }
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerBreakAfter)
            {
                return(new Status(Status.OK));
            }

            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                string id       = this.properties.GetProperty("id").GetString();
                int    align    = this.properties.GetProperty("text-align").GetEnum();
                int    valign   = this.properties.GetProperty("vertical-align").GetEnum();
                int    overflow = this.properties.GetProperty("overflow").GetEnum();

                this.breakBefore = this.properties.GetProperty("break-before").GetEnum();
                this.breakAfter  = this.properties.GetProperty("break-after").GetEnum();
                this.width       = this.properties.GetProperty("width").GetLength().MValue();
                this.height      = this.properties.GetProperty("height").GetLength().MValue();
                this.contwidth   =
                    this.properties.GetProperty("content-width").GetLength().MValue();
                this.contheight =
                    this.properties.GetProperty("content-height").GetLength().MValue();
                this.wauto  = this.properties.GetProperty("width").GetLength().IsAuto();
                this.hauto  = this.properties.GetProperty("height").GetLength().IsAuto();
                this.cwauto =
                    this.properties.GetProperty("content-width").GetLength().IsAuto();
                this.chauto =
                    this.properties.GetProperty("content-height").GetLength().IsAuto();

                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();

                this.scaling = this.properties.GetProperty("scaling").GetEnum();

                area.getIDReferences().CreateID(id);
                if (this.areaCurrent == null)
                {
                    this.areaCurrent =
                        new ForeignObjectArea(propMgr.GetFontState(area.getFontInfo()),
                                              area.getAllocationWidth());

                    this.areaCurrent.start();
                    areaCurrent.SetWidth(this.width);
                    areaCurrent.SetHeight(this.height);
                    areaCurrent.SetContentWidth(this.contwidth);
                    areaCurrent.setContentHeight(this.contheight);
                    areaCurrent.setScaling(this.scaling);
                    areaCurrent.setAlign(align);
                    areaCurrent.setVerticalAlign(valign);
                    areaCurrent.setOverflow(overflow);
                    areaCurrent.setSizeAuto(wauto, hauto);
                    areaCurrent.setContentSizeAuto(cwauto, chauto);

                    areaCurrent.setPage(area.getPage());

                    int numChildren = this.children.Count;
                    if (numChildren > 1)
                    {
                        throw new FonetException("Only one child element is allowed in an instream-foreign-object");
                    }
                    if (this.children.Count > 0)
                    {
                        FONode fo = (FONode)children[0];
                        Status status;
                        if ((status =
                                 fo.Layout(this.areaCurrent)).isIncomplete())
                        {
                            return(status);
                        }
                        this.areaCurrent.end();
                    }
                }

                this.marker = 0;

                if (breakBefore == BreakBefore.PAGE ||
                    ((spaceBefore + areaCurrent.getEffectiveHeight())
                     > area.spaceLeft()))
                {
                    return(new Status(Status.FORCE_PAGE_BREAK));
                }

                if (breakBefore == BreakBefore.ODD_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_ODD));
                }

                if (breakBefore == BreakBefore.EVEN_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
                }
            }

            if (this.areaCurrent == null)
            {
                return(new Status(Status.OK));
            }

            if (area is BlockArea)
            {
                BlockArea ba = (BlockArea)area;
                LineArea  la = ba.getCurrentLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.addPending();
                if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth())
                {
                    la = ba.createNextLineArea();
                    if (la == null)
                    {
                        return(new Status(Status.AREA_FULL_NONE));
                    }
                }
                la.addInlineArea(areaCurrent, GetLinkSet());
            }
            else
            {
                area.addChild(areaCurrent);
                area.increaseHeight(areaCurrent.getEffectiveHeight());
            }

            if (this.isInTableCell)
            {
                startIndent += forcedStartOffset;
            }

            areaCurrent.setStartIndent(startIndent);
            areaCurrent.setPage(area.getPage());

            if (breakAfter == BreakAfter.PAGE)
            {
                this.marker = MarkerBreakAfter;
                return(new Status(Status.FORCE_PAGE_BREAK));
            }

            if (breakAfter == BreakAfter.ODD_PAGE)
            {
                this.marker = MarkerBreakAfter;
                return(new Status(Status.FORCE_PAGE_BREAK_ODD));
            }

            if (breakAfter == BreakAfter.EVEN_PAGE)
            {
                this.marker = MarkerBreakAfter;
                return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
            }

            areaCurrent = null;
            return(new Status(Status.OK));
        }
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Page-number-citation outside block area");
                return(new Status(Status.OK));
            }

            IDReferences idReferences = area.getIDReferences();

            this.area = area;
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                ColorType c = this.properties.GetProperty("color").GetColorType();
                this.red   = c.Red;
                this.green = c.Green;
                this.blue  = c.Blue;

                this.wrapOption         = this.properties.GetProperty("wrap-option").GetEnum();
                this.whiteSpaceCollapse =
                    this.properties.GetProperty("white-space-collapse").GetEnum();

                this.refId = this.properties.GetProperty("ref-id").GetString();

                if (this.refId.Equals(""))
                {
                    throw new FonetException("page-number-citation must contain \"ref-id\"");
                }

                this.id = this.properties.GetProperty("id").GetString();
                idReferences.CreateID(id);
                ts = new TextState();

                this.marker = 0;
            }

            if (marker == 0)
            {
                idReferences.ConfigureID(id, area);
            }


            pageNumber = idReferences.getPageNumber(refId);

            if (pageNumber != null)
            {
                this.marker =
                    FOText.addText((BlockArea)area,
                                   propMgr.GetFontState(area.getFontInfo()), red,
                                   green, blue, wrapOption, null,
                                   whiteSpaceCollapse, pageNumber.ToCharArray(),
                                   0, pageNumber.Length, ts,
                                   VerticalAlign.BASELINE);
            }
            else
            {
                BlockArea blockArea = (BlockArea)area;
                LineArea  la        = blockArea.getCurrentLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.changeFont(propMgr.GetFontState(area.getFontInfo()));
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                la.addPageNumberCitation(refId, null);
                this.marker = -1;
            }

            if (this.marker == -1)
            {
                return(new Status(Status.OK));
            }
            else
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
        }
Exemple #23
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align       = this.properties.GetProperty("text-align").GetEnum();
                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();

                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();

                this.width  = this.properties.GetProperty("width").GetLength().MValue();
                this.height = this.properties.GetProperty("height").GetLength().MValue();

                this.src = this.properties.GetProperty("src").GetString();
                this.id  = this.properties.GetProperty("id").GetString();

                area.getIDReferences().CreateID(id);
                this.marker = 0;
            }

            try
            {
                FonetImage img = FonetImageFactory.Make(src);
                if ((width == 0) || (height == 0))
                {
                    double imgWidth  = img.Width;
                    double imgHeight = img.Height;

                    if ((width == 0) && (height == 0))
                    {
                        width  = (int)((imgWidth * 1000d));
                        height = (int)((imgHeight * 1000d));
                    }
                    else if (height == 0)
                    {
                        height = (int)((imgHeight * ((double)width)) / imgWidth);
                    }
                    else if (width == 0)
                    {
                        width = (int)((imgWidth * ((double)height)) / imgHeight);
                    }
                }

                double ratio = (double)width / (double)height;

                Length maxWidth  = this.properties.GetProperty("max-width").GetLength();
                Length maxHeight = this.properties.GetProperty("max-height").GetLength();

                if (maxWidth != null && width > maxWidth.MValue())
                {
                    width  = maxWidth.MValue();
                    height = (int)(((double)width) / ratio);
                }
                if (maxHeight != null && height > maxHeight.MValue())
                {
                    height = maxHeight.MValue();
                    width  = (int)(ratio * ((double)height));
                }

                int areaWidth  = area.getAllocationWidth() - startIndent - endIndent;
                int pageHeight = area.getPage().getBody().getMaxHeight() - spaceBefore;

                if (height > pageHeight)
                {
                    height = pageHeight;
                    width  = (int)(ratio * ((double)height));
                }
                if (width > areaWidth)
                {
                    width  = areaWidth;
                    height = (int)(((double)width) / ratio);
                }

                if (area.spaceLeft() < (height + spaceBefore))
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }

                this.imageArea =
                    new ImageArea(propMgr.GetFontState(area.getFontInfo()), img,
                                  area.getAllocationWidth(), width, height,
                                  startIndent, endIndent, align);

                if ((spaceBefore != 0) && (this.marker == 0))
                {
                    area.addDisplaySpace(spaceBefore);
                }

                if (marker == 0)
                {
                    area.GetMyRefs().ConfigureID(id, area);
                }

                imageArea.start();
                imageArea.end();

                if (spaceAfter != 0)
                {
                    area.addDisplaySpace(spaceAfter);
                }
                if (breakBefore == BreakBefore.PAGE ||
                    ((spaceBefore + imageArea.GetHeight())
                     > area.spaceLeft()))
                {
                    return(new Status(Status.FORCE_PAGE_BREAK));
                }

                if (breakBefore == BreakBefore.ODD_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_ODD));
                }

                if (breakBefore == BreakBefore.EVEN_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
                }

                if (area is BlockArea)
                {
                    BlockArea ba = (BlockArea)area;
                    LineArea  la = ba.getCurrentLineArea();
                    if (la == null)
                    {
                        return(new Status(Status.AREA_FULL_NONE));
                    }
                    la.addPending();
                    if (imageArea.getContentWidth() > la.getRemainingWidth())
                    {
                        la = ba.createNextLineArea();
                        if (la == null)
                        {
                            return(new Status(Status.AREA_FULL_NONE));
                        }
                    }
                    la.addInlineArea(imageArea, GetLinkSet());
                }
                else
                {
                    area.addChild(imageArea);
                    area.increaseHeight(imageArea.getContentHeight());
                }
                imageArea.setPage(area.getPage());

                if (breakAfter == BreakAfter.PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return(new Status(Status.FORCE_PAGE_BREAK));
                }

                if (breakAfter == BreakAfter.ODD_PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return(new Status(Status.FORCE_PAGE_BREAK_ODD));
                }

                if (breakAfter == BreakAfter.EVEN_PAGE)
                {
                    this.marker = MarkerBreakAfter;
                    return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
                }
            }
            catch (FonetImageException imgex)
            {
                FonetDriver.ActiveDriver.FireFonetError("Error while creating area : " + imgex.Message);
            }

            return(new Status(Status.OK));
        }
Exemple #24
0
        public static int addText(BlockArea ba, FontState fontState, float red,
                                  float green, float blue, WrapOption wrapOption,
                                  LinkSet ls, int whiteSpaceCollapse,
                                  char[] data, int start, int end,
                                  TextState textState, VerticalAlign vAlign)
        {
            if (fontState.FontVariant == FontVariant.SMALL_CAPS)
            {
                FontState smallCapsFontState;
                try
                {
                    int smallCapsFontHeight =
                        (int)(((double)fontState.FontSize) * 0.8d);
                    smallCapsFontState = new FontState(fontState.FontInfo,
                                                       fontState.FontFamily,
                                                       fontState.FontStyle,
                                                       fontState.FontWeight,
                                                       smallCapsFontHeight,
                                                       FontVariant.NORMAL);
                }
                catch (FonetException ex)
                {
                    smallCapsFontState = fontState;
                    FonetDriver.ActiveDriver.FireFonetError(
                        "Error creating small-caps FontState: " + ex.Message);
                }

                char      c;
                bool      isLowerCase;
                int       caseStart;
                FontState fontStateToUse;
                for (int i = start; i < end;)
                {
                    caseStart   = i;
                    c           = data[i];
                    isLowerCase = (Char.IsLetter(c) && Char.IsLower(c));
                    while (isLowerCase == (Char.IsLetter(c) && Char.IsLower(c)))
                    {
                        if (isLowerCase)
                        {
                            data[i] = Char.ToUpper(c);
                        }
                        i++;
                        if (i == end)
                        {
                            break;
                        }
                        c = data[i];
                    }
                    if (isLowerCase)
                    {
                        fontStateToUse = smallCapsFontState;
                    }
                    else
                    {
                        fontStateToUse = fontState;
                    }
                    int index = addRealText(ba, fontStateToUse, red, green, blue,
                                            wrapOption, ls, whiteSpaceCollapse,
                                            data, caseStart, i, textState,
                                            vAlign);
                    if (index != -1)
                    {
                        return(index);
                    }
                }

                return(-1);
            }

            return(addRealText(ba, fontState, red, green, blue, wrapOption, ls,
                               whiteSpaceCollapse, data, start, end, textState,
                               vAlign));
        }
Exemple #25
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginProps           mProps    = propMgr.GetMarginProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                this.align      = this.properties.GetProperty("text-align").GetEnum();
                this.alignLast  = this.properties.GetProperty("text-align-last").GetEnum();
                this.lineHeight =
                    this.properties.GetProperty("line-height").GetLength().MValue();
                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();

                this.marker = 0;

                if (area is BlockArea)
                {
                    area.end();
                }

                if (spaceBefore != 0)
                {
                    area.addDisplaySpace(spaceBefore);
                }

                if (this.isInTableCell)
                {
                    startIndent += forcedStartOffset;
                    endIndent   += area.getAllocationWidth() - forcedWidth
                                   - forcedStartOffset;
                }

                string id = this.properties.GetProperty("id").GetString();
                area.getIDReferences().InitializeID(id, area);
            }

            BlockArea blockArea =
                new BlockArea(propMgr.GetFontState(area.getFontInfo()),
                              area.getAllocationWidth(), area.spaceLeft(),
                              startIndent, endIndent, 0, align, alignLast,
                              lineHeight);

            blockArea.setTableCellXOffset(area.getTableCellXOffset());
            blockArea.setGeneratedBy(this);
            this.areasGenerated++;
            if (this.areasGenerated == 1)
            {
                blockArea.isFirst(true);
            }
            blockArea.addLineagePair(this, this.areasGenerated);

            blockArea.setParent(area);
            blockArea.setPage(area.getPage());
            blockArea.setBackground(propMgr.GetBackgroundProps());
            blockArea.start();

            blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
            blockArea.setIDReferences(area.getIDReferences());

            int numChildren = this.children.Count;

            for (int i = this.marker; i < numChildren; i++)
            {
                if (!(children[i] is ListItem))
                {
                    FonetDriver.ActiveDriver.FireFonetError(
                        "Children of list-blocks must be list-items");
                    return(new Status(Status.OK));
                }
                ListItem listItem = (ListItem)children[i];
                Status   status;
                if ((status = listItem.Layout(blockArea)).isIncomplete())
                {
                    if (status.getCode() == Status.AREA_FULL_NONE && i > 0)
                    {
                        status = new Status(Status.AREA_FULL_SOME);
                    }
                    this.marker = i;
                    blockArea.end();
                    area.addChild(blockArea);
                    area.increaseHeight(blockArea.GetHeight());
                    return(status);
                }
            }

            blockArea.end();
            area.addChild(blockArea);
            area.increaseHeight(blockArea.GetHeight());

            if (spaceAfter != 0)
            {
                area.addDisplaySpace(spaceAfter);
            }

            if (area is BlockArea)
            {
                area.start();
            }

            blockArea.isLast(true);
            return(new Status(Status.OK));
        }
Exemple #26
0
    // Runtime Properties Required for instantiating a destroyed projectile (load/save state)


    //private int opProjectileLayer;
    //private int opProjectileMask;

    void Start()
    {
        gameObject.AddComponent <SphereCollider>();


        if (mirror == 1)
        {
            directionVector.x = -1;
        }

        if (totalHits == int.MinValue)
        {
            totalHits = data.totalHits;
        }

        Fix64 angleRad = ((Fix64)data.directionAngle / 180) * FPMath.Pi;

        movement = ((FPMath.Sin(angleRad) * FPVector.up) + (FPMath.Cos(angleRad) * directionVector)) * data.speed;
        fpTransform.Translate(new FPVector(data._castingOffSet.x * -mirror, data._castingOffSet.y, data._castingOffSet.z));

        // Create Blockable Area
        blockableArea = new BlockArea();
        blockableArea = data.blockableArea;

        // Create Hurtbox
        hurtBox = new HurtBox();
        hurtBox = data.hurtBox;

        // Create Hitbox
        hitBox               = new HitBox();
        hitBox.shape         = hurtBox.shape;
        hitBox._rect         = hurtBox._rect;
        hitBox.followXBounds = hurtBox.followXBounds;
        hitBox.followYBounds = hurtBox.followYBounds;
        hitBox._radius       = hurtBox._radius;
        hitBox._offSet       = hurtBox._offSet;
        hitBox.position      = gameObject.transform;

        UpdateRenderer();

        if (data.spaceBetweenHits == Sizes.Small)
        {
            spaceBetweenHits = .15;
        }
        else if (data.spaceBetweenHits == Sizes.Medium)
        {
            spaceBetweenHits = .2;
        }
        else if (data.spaceBetweenHits == Sizes.High)
        {
            spaceBetweenHits = .3;
        }


        // Create Hit data
        hit                             = new Hit();
        hit.hitType                     = data.hitType;
        hit.spaceBetweenHits            = data.spaceBetweenHits;
        hit.hitStrength                 = data.hitStrength;
        hit.hitStunType                 = HitStunType.Frames;
        hit._hitStunOnHit               = data.hitStunOnHit;
        hit._hitStunOnBlock             = data.hitStunOnBlock;
        hit._damageOnHit                = data._damageOnHit;
        hit._damageOnBlock              = data._damageOnBlock;
        hit.damageScaling               = data.damageScaling;
        hit.damageType                  = data.damageType;
        hit.groundHit                   = data.groundHit;
        hit.airHit                      = data.airHit;
        hit.downHit                     = data.downHit;
        hit.overrideHitEffects          = data.overrideHitEffects;
        hit.armorBreaker                = data.armorBreaker;
        hit.hitEffects                  = data.hitEffects;
        hit.resetPreviousHorizontalPush = data.resetPreviousHorizontalPush;
        hit.resetPreviousVerticalPush   = data.resetPreviousVerticalPush;
        hit.applyDifferentAirForce      = data.applyDifferentAirForce;
        hit.applyDifferentBlockForce    = data.applyDifferentBlockForce;
        hit._pushForce                  = data._pushForce;
        hit._pushForceAir               = data._pushForceAir;
        hit._pushForceBlock             = data._pushForceBlock;
        hit.pullEnemyIn                 = new PullIn();
        hit.pullEnemyIn.enemyBodyPart   = BodyPart.none;

        if (data.mirrorOn2PSide && mirror > 0)
        {
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y + 180, transform.localEulerAngles.z);
        }
    }
 /// <summary>
 /// Overideable function for map generation
 /// </summary>
 /// <returns></returns>
 public abstract Map Generate(Map map, BlockArea area);