Exemplo n.º 1
0
        public void AddToFlockP1(Flock.FlockAnimalInfo info, FlockAnimal prevAnimal)
        {
            myFlock          = info.myFlock;
            xLinePosition    = info.xLinePosition;
            position.x       = info.xLinePosition;
            position.y       = myFlock.yPositionStart;
            yUndulationTimer = info.yUndulationTimer;
            yUndulationTime  = info.yUndulationTime;
            flockAnimalType  = (FlockAnimalType)info.animalType;
            flockAnimalId    = info.flockAnimalId;
            hasMarkerForAI   = info.hasMarkerForAI;
            markerOffset     = info.markerOffset;
            if (flockAnimalType == FlockAnimalType.kFlockAnimalShirley)
            {
                undulationDistance = 20.0f;
            }
            else
            {
                undulationDistance = 40.0f;
            }

            if (flockAnimalType == FlockAnimalType.kFlockAnimalPenguin)
            {
                hasShadow = false;
            }
            else
            {
                hasShadow = true;
            }

            framesForUndulationCycle = (int)(info.yUndulationTime / Constants.kFrameRate);
            if (prevAnimal == null)
            {
                yStartPosition = myFlock.yPositionStart;
                int framesAdded = (int)(info.yUndulationTimer / Constants.kFrameRate);
                undulationStartFrame = (int)(framesAdded % framesForUndulationCycle);
                if (undulationStartFrame < 0)
                {
                    undulationStartFrame += framesForUndulationCycle;
                }
            }
            else
            {
                yStartPosition = prevAnimal.yStartPosition - info.distanceToGo;
                float distanceFromStart = myFlock.yPositionStart - yStartPosition;
                int   framesSinceStart  = (int)(distanceFromStart / myFlock.speed);
                int   framesAdded       = (int)((info.yUndulationTimer) / Constants.kFrameRate);
                int   totalNewFrames    = -framesSinceStart + framesAdded;
                undulationStartFrame = (int)(totalNewFrames % framesForUndulationCycle);
                if (undulationStartFrame < 0)
                {
                    undulationStartFrame += framesForUndulationCycle;
                }
            }

            mapObjectId = (Globals.g_world.game).AddMapObjectP1P2P3P4(TextureType.kTexture_DontAddThisMapObjectToPendingList, (int)100, (int)-300,
                                                                      ListType.e_RenderAbovePlayer, 0);
            Globals.Assert(!(Globals.g_world.game).IsMapObjectIdInvalid(mapObjectId));
            mapObject = (Globals.g_world.game).GetMapObject(mapObjectId);
            mapObject.SetType(MapObjectType.e_FlockAnimal);
            mapObject.SetSubTextureId(0);
            const float kMinScale = 0.73f;
            const float kMaxScale = 1.0f;
            float       range     = kMaxScale - kMinScale;
            float       rPlus     = Utilities.GetRandBetweenP1(0.0f, range);
            float       rThing    = kMinScale + rPlus;

            mapObject.SetScale(rThing);
            mapObject.SetIsSelfRemoving(false);
            shadowMapObjectId = -1;
            if (hasShadow)
            {
                shadowMapObjectId = (Globals.g_world.game).AddMapObjectP1P2P3P4(TextureType.kTexture_DontAddThisMapObjectToPendingList, (int)-100, (int)-300,
                                                                                ListType.e_Shadows, 0);
            }

            Globals.Assert(!(Globals.g_world.game).IsMapObjectIdInvalid(mapObjectId));
            if (hasShadow)
            {
                Globals.Assert(!(Globals.g_world.game).IsMapObjectIdInvalid(shadowMapObjectId));
                shadowMapObject = (Globals.g_world.game).GetMapObject(shadowMapObjectId);
                shadowMapObject.SetIsSelfRemoving(false);

                shadowMapObject.SetAtlas(Globals.g_world.game.gameThingsAtlas);                //
                if (((Globals.g_world.game).lBuilder).currentScene == (int)SceneType.kSceneMud)
                {
                    shadowMapObject.SetSubTextureId((int)World.Enum2.kGTMud_PlayerShadow);
                    shadowMapObject.SetAtlas(Globals.g_world.game.gameThingsAtlas);// .SetSubTextureId((int)World.Enum2.kGTMud_PlayerShadow);
                }
                else
                {
                    shadowMapObject.SetSubTextureId((int)World.Enum3.kGTGrass_PlayerShadow);
                }
            }

            float noGoRadius = 0.0f;

            if (flockAnimalType == FlockAnimalType.kFlockAnimalCow)
            {
                shadowMapObject.SetScale(1.0f);
                noGoRadius = 42.0f;
            }
            else if (flockAnimalType == FlockAnimalType.kFlockAnimalSheep)
            {
                shadowMapObject.SetScale(1.7f * rThing);
                noGoRadius = 42.0f;
            }
            else if (flockAnimalType == FlockAnimalType.kFlockAnimalPenguin)
            {
                noGoRadius = 20.0f;
            }
            else if (flockAnimalType == FlockAnimalType.kFlockAnimalZebra)
            {
                shadowMapObject.SetScale(1.5f);
                noGoRadius = 35.0f;
            }
            else if (flockAnimalType == FlockAnimalType.kFlockAnimalShirley)
            {
                shadowMapObject.SetScale(2.7f);
                noGoRadius = 70.0f;
            }
            else
            {
                Globals.Assert(false);
            }

            if (noGoZone == null)
            {
                noGoZone = new NoGoZone();
            }

            noGoZone.InitialiseP1(Utilities.CGPointMake(0, 0), noGoRadius);
            noGoZone.SetType(NoGoType.e_FlockAnimal);
            noGoZone.SetObjectId(myFlock.flockId);
            noGoZone.SetShadowObjectId(flockAnimalId);
        }
Exemplo n.º 2
0
        public void AddToScene(CrossingThingInfo info)
        {
            numAnims = -1;
            switch ((CrossingThingType)info.crossingThingType)
            {
            case CrossingThingType.kCrossingThing_Elephant:
                xSpeed = -1.0f;
                break;

            case CrossingThingType.kCrossingThing_Snake:
                xSpeed            = -2.0f;
                animMinSubTexture = 0;                //kGTJungle_Snake1;
                numAnims          = 3;
                break;

            case CrossingThingType.kCrossingThing_Shirley:
                xSpeed            = 0.5f;
                animMinSubTexture = 0;
                numAnims          = 3;
                break;

            case CrossingThingType.kCrossingThing_Tractor:
                xSpeed            = -3.0f;
                animMinSubTexture = (short)World.Enum2.kGTMud_Tractor;
                numAnims          = 1;
                break;

            case CrossingThingType.kCrossingThing_LandRover:
                xSpeed            = 4.5f;
                animMinSubTexture = (short)World.Enum2.kGTMud_LandRover;
                numAnims          = 1;
                break;

            case CrossingThingType.kCrossingThing_Sheep:
                xSpeed = info.xSpeed;
                if (xSpeed < 0.0f)
                {
                    animMinSubTexture = (short)World.Enum3.kGTGrass_CowLeft1;
                }
                else
                {
                    animMinSubTexture = (short)World.Enum3.kGTGrass_CowRight1;
                }

                numAnims = 3;
                break;

            default:
                xSpeed = -1.0f;
                break;
            }

            framesToCrossMap  = (short)((Constants.MAP_WIDTH + (kMapEdgeBuffer * 2.0f)) / -xSpeed);
            startPosition     = info.startPosition;
            position          = info.startPosition;
            crossingThingType = info.crossingThingType;
            crossingThingId   = info.crossingThingId;
            mapObjectId       = (short)(Globals.g_world.game).AddMapObjectP1P2P3P4((TextureType)0, (int)100, (int)-300, ListType.e_RenderAbovePlayer, 0.0f);
            Globals.Assert(!(Globals.g_world.game).IsMapObjectIdInvalid(mapObjectId));
            mapObject = (Globals.g_world.game).GetMapObject(mapObjectId);
            mapObject.SetType(MapObjectType.e_CrossingThing);
            mapObject.SetSubTextureId(animMinSubTexture);
            if (((Globals.g_world.game).lBuilder).currentScene == (int)SceneType.kSceneMud)
            {
                mapObject.SetRotationScale((Globals.g_world.GetAtlas(AtlasType.kAtlas_GameThingsMud)).GetSubTextureRotationScale(animMinSubTexture));
            }
            else
            {
                mapObject.SetRotationScale((Globals.g_world.GetAtlas(AtlasType.kAtlas_GameThingsGrass)).GetSubTextureRotationScale(animMinSubTexture));
            }

            mapObject.SetIsSelfRemoving(false);
            mapObject.SetScale(Constants.SPRITE_BASE_SCALE);
            shadowMapObjectId = -1;
            if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Elephant)
            {
                shadowMapObjectId = (short)(Globals.g_world.game).AddMapObjectP1P2P3P4((TextureType)0, (int)-100, (int)-300, ListType.e_Shadows, 0);
            }

            Globals.Assert(!(Globals.g_world.game).IsMapObjectIdInvalid(mapObjectId));
            if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Elephant)
            {
                Globals.Assert(!(Globals.g_world.game).IsMapObjectIdInvalid(shadowMapObjectId));
                shadowMapObject = (Globals.g_world.game).GetMapObject(shadowMapObjectId);
                shadowMapObject.SetSubTextureId(1);
                shadowMapObject.SetIsSelfRemoving(false);
            }

            float noGoRadius = 0.0f;

            if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Elephant)
            {
                shadowMapObject.SetScale(2.0f);
                noGoRadius = 42.0f;
            }
            else if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Snake)
            {
                noGoRadius = 30.0f;
            }
            else if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Shirley)
            {
                noGoRadius = 50.0f;
            }
            else if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Sheep)
            {
                noGoRadius = 30.0f;
            }
            else if (((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Tractor) || ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_LandRover))
            {
                noGoRadius = 80.0f;
            }
            else
            {
                Globals.Assert(false);
            }

            if (noGoZone == null)
            {
                noGoZone = new NoGoZone();
            }

            noGoZone.InitialiseP1(Utilities.CGPointMake(0, 0), noGoRadius);
            noGoZone.SetType(NoGoType.e_CrossingThing);
            noGoZone.SetObjectId(crossingThingId);
            noGoZone.SetShadowObjectId(crossingThingId);
            noGoZone.SetIsBouncable(true);
            noGoZone.SetCeilingHeight(20.0f);
        }
Exemplo n.º 3
0
        public void Initialise(RiverInfo info)
        {
            for (int i = 0; i < 12; i++)
            {
                if (myAtlasBillboard[i] == null)
                {
                    myAtlasBillboard[i] = new Billboard("river");
                }

                myAtlasBillboard[i].StopRender();

                myAtlasBillboard[i].SetAtlas(Globals.g_world.GetAtlas((int)AtlasType.kAtlas_GrassTiles));

                myAtlasBillboard[i].myObject.GetComponent <Renderer>().sharedMaterial = Globals.g_world.GetAtlas((int)AtlasType.kAtlas_GrassTiles).myMaterialTransparent;

                //int tileSubtexture = ((Globals.g_world.game).lBuilder).GetTileMapTileP1P2((int) AtlasType.kAtlas_GrassTiles, bridgeX + x, bridgeY + y);

                myAtlasBillboard[i].SetDetailsFromAtlas(Globals.g_world.GetAtlas((int)AtlasType.kAtlas_GrassTiles), 0);

                //
//								myAtlasBillboard[i].myObject.GetComponent<MeshRenderer>().sharedMaterial = Globals.g_main.grassSpriteAtlas;
//								Globals.g_main.grassSpriteAtlas.SetTexture("_MainTex",);
            }

            isBeingDrawn = false;

            riverType = info.riverType;
            if (false)
            {
                yCliffStart  = (float)info.yPos - 32 + 94 - 15 - 40.0f;
                yCliffLength = (float)(340);
                raiseLength  = 120.0f;
            }
            else
            {
                yCliffStart  = (float)info.yPos - 32 + 60 - 15 - 40.0f;
                yCliffLength = (float)(400);
                raiseLength  = 80.0f;
            }

            xFlowerPosition = (float)info.xPosBridge;
            xWidth          = (float)info.widthBridge;
            CGPoint stemPosition = Utilities.CGPointMake(xFlowerPosition, yCliffStart + yCliffLength - 65.0f);

            if (xWidth == 128.0f)
            {
                if (xFlowerPosition == 320.0f)
                {
                    stemPosition.x -= 8.0f;
                }
                else if (xFlowerPosition == 64.0f)
                {
                    stemPosition.x += 8.0f;
                }
            }

            if (info.widthBridge == 64)
            {
                noGoStem.InitialiseP1(stemPosition, 30);
            }
            else
            {
                noGoStem.InitialiseP1(stemPosition, 65);
            }

            noGoStem.SetGroundLevel(-Game.kClifffDepth);
            noGoStem.SetType(NoGoType.e_Bridge);
        }