Ejemplo n.º 1
0
    private void AddChest(Vector3 location, bool locked, bool trapped, bool addHealth)
    {
        int id = Game.EntityManager.CreateEntity();

        var formComp = new FormComponent();

        formComp.InitComponent(id, location, "Chest001", "Chest001_Broken");
        Game.EntityManager.AddComponent(id, formComp);

        var openComp = new OpenComponent();

        openComp.InitComponent(null);
        Game.EntityManager.AddComponent(id, openComp);

        var animComp = new AnimationComponent();

        animComp.InitComponent(null);
        animComp.Animations.Add(new AnimationSystem.AnimationData()
        {
            EntityID = id, Name = "ChestClose", Sound = "ChestClose001", DisablePhysics = true, TriggerEvent = RPGGameEvent.Menu_Close
        });
        animComp.Animations.Add(new AnimationSystem.AnimationData()
        {
            EntityID = id, Name = "ChestOpen90", Sound = "ChestOpen001", DisablePhysics = true, TriggerEvent = RPGGameEvent.Menu_Open
        });
        Game.EntityManager.AddComponent(id, animComp);

        if (locked)
        {
            var lockComp = new LockComponent();
            lockComp.InitComponent(null);
            lockComp.InitComponent(44);
            Game.EntityManager.AddComponent(id, lockComp);
        }

        if (trapped)
        {
            var trapComp = new TrapComponent();
            trapComp.InitComponent(formComp, new EffectSystem.EffectData()
            {
                AreaOfEffectRadius = 10,
                Duration           = 5,
                PrefabName         = "AOE/Fireball",
                TargetType         = EffectSystem.TargetTypeEnum.AreaOfEffect,
                Damage             = new DieRollData(2, 4, 0, 0),
                DamageType         = AttackSystem.DamageTypes.Crush,
                Description_Attack = "Fireball Blast"
            });
            Game.EntityManager.AddComponent(id, trapComp);
        }

        if (addHealth)
        {
            var health = new HealthComponent()
            {
                Damage = 0, DeathType = HealthComponent.DeathTypes.Broken, HP_Max = 5000
            };
            Game.EntityManager.AddComponent(id, health);
        }
    }
Ejemplo n.º 2
0
        public void createBlockEntity(float x, float y)
        {
            if (level.getCollisionSystem().findObjectsBetweenPoints(x - spawnBlockSize / 2, y - spawnBlockSize / 2, x + spawnBlockSize / 2, y + spawnBlockSize / 2).Count > 0)
            {
                return;
            }
            if (level.getCollisionSystem().findObjectsBetweenPoints(x - spawnBlockSize / 2, y + spawnBlockSize / 2, x + spawnBlockSize / 2, y - spawnBlockSize / 2).Count > 0)
            {
                return;
            }

            if (spawnBlocks.Count >= maxNumSpawnBlocks)
            {
                spawnBlockEntity   old      = spawnBlocks.Dequeue();
                DrawComponent      drawComp = ( DrawComponent )old.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
                AnimationComponent animComp = ( AnimationComponent)old.getComponent(GlobalVars.ANIMATION_COMPONENT_NAME);
                if (animComp != null && drawComp != null)
                {
                    ColliderComponent colComp = (ColliderComponent)old.getComponent(GlobalVars.COLLIDER_COMPONENT_NAME);
                    colComp.colliderType = GlobalVars.DESTROYING_SPAWN_BLOCK_COLLIDER_TYPE;
                    drawComp.setSprite(old.blockAnimationName);
                    animComp.animationOn = true;
                }
                else
                {
                    level.removeEntity(old);
                }
            }
            //Entity newEntity = new [YOUR ENTITY HERE](level, x, y);
            spawnBlockEntity newEntity = new spawnBlockEntity(level, x, y);

            level.addEntity(newEntity.randId, newEntity);   //This should just stay the same
            spawnBlocks.Enqueue(newEntity);
        }
Ejemplo n.º 3
0
    static int GetComponents(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);
            Type        arg0       = LuaScriptMgr.GetTypeObject(L, 2);
            Component[] o          = obj.GetComponents(arg0);
            LuaScriptMgr.PushArray(L, o);
            return(1);
        }
        else if (count == 3)
        {
            AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);
            Type             arg0  = LuaScriptMgr.GetTypeObject(L, 2);
            List <Component> arg1  = LuaScriptMgr.GetNetObject <List <Component> >(L, 3);
            obj.GetComponents(arg0, arg1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: AnimationComponent.GetComponents");
        }

        return(0);
    }
Ejemplo n.º 4
0
        public static ClientEntity ClientEntityFactory(EntityMessage em, BFBContentManager content)
        {
            IGraphicsComponent graphicsComponent = null;

            switch (em.EntityType)
            {
            case EntityType.Item:
                graphicsComponent = new ItemGraphicsComponent(content.GetAtlasTexture(em.TextureKey));
                break;

            case EntityType.Mob:
            case EntityType.Player:
            case EntityType.Projectile:
            case EntityType.Particle:
                graphicsComponent = new AnimationComponent(content.GetAnimatedTexture(em.TextureKey));
                break;
            }

            return(new ClientEntity(em.EntityId,
                                    new EntityOptions
            {
                Dimensions = em.Dimensions,
                Position = em.Position,
                Rotation = em.Rotation,
                Origin = em.Origin,
                EntityType = em.EntityType
            }, graphicsComponent));
        }
Ejemplo n.º 5
0
    static int IsInvoking(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);
            bool o = obj.IsInvoking();
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2)
        {
            AnimationComponent obj  = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);
            string             arg0 = LuaScriptMgr.GetLuaString(L, 2);
            bool o = obj.IsInvoking(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: AnimationComponent.IsInvoking");
        }

        return(0);
    }
Ejemplo n.º 6
0
    static int GetComponent(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        Type[] types0 = { typeof(AnimationComponent), typeof(string) };
        Type[] types1 = { typeof(AnimationComponent), typeof(Type) };

        if (count == 2 && LuaScriptMgr.CheckTypes(L, types0, 1))
        {
            AnimationComponent obj  = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);
            string             arg0 = LuaScriptMgr.GetString(L, 2);
            Component          o    = obj.GetComponent(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, types1, 1))
        {
            AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);
            Type      arg0         = LuaScriptMgr.GetTypeObject(L, 2);
            Component o            = obj.GetComponent(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: AnimationComponent.GetComponent");
        }

        return(0);
    }
Ejemplo n.º 7
0
    static int Lua_ToString(IntPtr L)
    {
        AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1);

        LuaScriptMgr.Push(L, obj.ToString());
        return(1);
    }
Ejemplo n.º 8
0
        public override void EventFired(object sender, Event evt)
        {
            if (evt is SoftCollisionEvent ce &&
                ce.Sender.Owner.Components.Get <EnergyRefillComponent>() is EnergyRefillComponent refill &&
                refill.Enabled &&
                ce.Victim.Components.Get <PulseAbility>() is PulseAbility pulse)
            {
                pulse.EnergyMeter = pulse.MaxEnergy;
                refill.Enabled    = false;
                Transform sp = refill.Owner.GetComponent <Transform>();
                if (sp != null)
                {
                    Owner.Entities.Add(new SoundParticle(sp.Position));
                }
                Owner.Controller.AudioUnit["refill"].Play();
                AnyDisabled = true;

                AnimationComponent animatable = refill.Owner.GetComponent <AnimationComponent>();
                if (animatable != null && animatable.Animations.Count >= 1 && animatable.Animations[0].SpriteIndex == 0)
                {
                    AnimatedSprite animation = animatable.Animations[0];
                    animation.Loop          = false;
                    animation.CurrentFrame  = 0;
                    animation.LoopFrame     = 0;
                    animation.FrameProgress = 0;
                    animation.FrameDuration = 3;
                    animation.FrameCount    = 6;
                    animation.Frame         = new Rectangle(64, 0, 16, 16);
                    animation.Step          = new Vector2D(16, 0);
                }
            }
        }
Ejemplo n.º 9
0
 public override void Update()
 {
     player = WatchedComponents.FirstOrDefault(c => c is PlayerMovementComponent) as PlayerMovementComponent;
     if (AnyDisabled && (player?.OnGround ?? false))
     {
         foreach (EnergyRefillComponent refill in WatchedComponents.OfType <EnergyRefillComponent>())
         {
             if (refill.Enabled)
             {
                 continue;
             }
             refill.Enabled = true;
             Renderable renderable = refill.Owner.GetComponent <Renderable>();
             if (renderable != null && renderable.Sprites.Count >= 1)
             {
                 renderable.Sprites[0].Source = new Rectangle(0, 0, 16, 16);
             }
             AnimationComponent animatable = refill.Owner.GetComponent <AnimationComponent>();
             if (animatable != null && animatable.Animations.Count >= 1 && animatable.Animations[0].SpriteIndex == 0)
             {
                 AnimatedSprite animation = animatable.Animations[0];
                 animation.Loop          = true;
                 animation.CurrentFrame  = 0;
                 animation.LoopFrame     = 5;
                 animation.FrameProgress = 0;
                 animation.FrameDuration = 8;
                 animation.FrameCount    = 9;
                 animation.Frame         = new Rectangle(128, 0, 16, 16);
                 animation.Step          = new Vector2D(-16, 0);
             }
         }
         AnyDisabled = false;
     }
 }
Ejemplo n.º 10
0
        public FreezeModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection)
        {
            this.info = (FreezeInfo)info;

            targetAnimationComponent = targetEntity.GetComponent <AnimationComponent>();
            targetMovementComponent  = targetEntity.GetComponent <MovementComponent>();
        }
        /// <summary>
        /// Creates Power Upp component and adds it to an entity
        /// </summary>
        /// <param name="id"></param>
        public void OnPowerUpPicup(int id)
        {
            BallOfSpikesPowerUpComponent temp = ComponentManager.Instance.GetEntityComponent <BallOfSpikesPowerUpComponent>(id);

            if (temp == null)
            {
                ComponentManager             test    = ComponentManager.Instance;
                BallOfSpikesPowerUpComponent ball    = new BallOfSpikesPowerUpComponent(5);
                DrawableComponent            newDraw = test.GetEntityComponent <DrawableComponent>(id);
                AnimationComponent           anima   = test.GetEntityComponent <AnimationComponent>(id);
                ball.prevTexture = newDraw.texture;
                newDraw.texture  = ball.SpikeTexture;
                if (anima != null)
                {
                    ball.anime = anima;
                    ComponentManager.Instance.RemoveComponentFromEntity(id, anima);
                }
                test.AddComponentToEntity(id, ball);


                CollisionRectangleComponent rec = ComponentManager.Instance.GetEntityComponent <CollisionRectangleComponent>(id);
                PositionComponent           pos = ComponentManager.Instance.GetEntityComponent <PositionComponent>(id);
                rec.CollisionRec   = new Rectangle((int)pos.position.X, (int)pos.position.Y, newDraw.texture.Width, newDraw.texture.Height);
                rec.CollisionRec.X = (int)pos.position.X;
                rec.CollisionRec.Y = (int)pos.position.Y;

                rec.CollisionRec.Width  = newDraw.texture.Width;
                rec.CollisionRec.Height = newDraw.texture.Height;
            }
            else
            {
                temp.lifeTime += 10;
            }
        }
Ejemplo n.º 12
0
        public override void OnStep(float deltaTime, bool shouldPause)
        {
            if (timeElapsedDuringDelay < DelaySeconds)
            {
                timeElapsedDuringDelay += deltaTime;
                return;
            }

            // NOTE: Pause is temporarily unsupported!
            if (!isPlayed)
            {
                AnimationComponent.Play(members[0].Clip.name);
                currentPlayingIndex = 0;
                isPlayed            = true;
            }

            if (currentPlayingIndex < playForList.Count && timeElapsedInSec >= playForList[currentPlayingIndex])
            {
                var nextIndex = currentPlayingIndex + 1;
                AnimationComponent.CrossFade(members[nextIndex].Clip.name, members[currentPlayingIndex].CrossFadeLength);
                currentPlayingIndex++;
            }

            if (IsDone())
            {
                FinalizeAction();
            }

            timeElapsedInSec += deltaTime;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Uppdates the position of the Change direction Cubes if they have been taken
        /// or if their timer has run out
        /// </summary>
        /// <param name="gameTime"></param>
        public void update(GameTime gameTime)
        {
            width  = Game.Instance.GraphicsDevice.Viewport.Width;
            height = Game.Instance.GraphicsDevice.Viewport.Height;

            if (entities.Count > 0)
            {
                foreach (var item in entities)
                {
                    ChangeCubeComponent change = ComponentManager.Instance.GetEntityComponent <ChangeCubeComponent>(item);

                    change.time += (float)gameTime.ElapsedGameTime.TotalSeconds;

                    if (change.isTaken || change.time > 5)
                    {
                        AnimationComponent ani = ComponentManager.Instance.GetEntityComponent <AnimationComponent>(item);
                        ani.currentFrame = 0;
                        PositionComponent pos = ComponentManager.Instance.GetEntityComponent <PositionComponent>(item);
                        pos.position.X = rand.Next(0, width);
                        pos.position.Y = rand.Next(0, height);
                        change.isTaken = false;
                        change.time    = 0;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public override void Prepare()
        {
            if (members.Count < 1)
            {
                throw new System.Exception("Memebers cannot be empty");
            }
            foreach (var member in members)
            {
                if (!AnimationComponent.GetClip(member.Clip.name))
                {
                    AnimationComponent.AddClip(member.Clip, member.Clip.name);
                }
            }

            playForList.Clear();
            var previousPlayfor = 0f;

            for (var i = 0; i < members.Count - 1; i++)
            {
                previousPlayfor += members[i].PlayFor;
                playForList.Add(previousPlayfor);
            }

            timeElapsedDuringDelay = 0f;
            timeElapsedInSec       = 0f;
            currentPlayingIndex    = 0;
            isPlayed = false;
            AnimationComponent.Stop();
        }
Ejemplo n.º 15
0
    private void OnOwnerJoined(SessionId userId)
    {
        AgentPrivate agent = ScenePrivate.FindAgent(userId);

        // Lookup the scene object for this agent
        ObjectPrivate agentObejct = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);

        if (agentObejct == null)
        {
            Log.Write($"Unable to find a ObjectPrivate component for user {userId}");
            return;
        }

        // Lookup the animation component. There should be just one, so grab the first
        AnimationComponent animationComponent = null;

        if (!agentObejct.TryGetFirstComponent(out animationComponent))
        {
            Log.Write($"Unable to find an animation component on user {userId}");
            return;
        }

        animationComponent.Subscribe(StartKey, StartSound);
        animationComponent.Subscribe(StopKey, StopSound);
    }
Ejemplo n.º 16
0
    public override void Update()
    {
        GameController gc = GameController.Instance;

        if (gc.scoreDirty || gc.livesDirty)
        {
            if (gc.matchStreak > 1)
            {
                AnimationComponent.Animate(
                    gc.streakText.GetComponentInParent <Animator>().gameObject,
                    "isStreak",
                    false,
                    null,
                    "anim_streaktext"
                    );

                gc.streakText.text = string.Format("{0} STREAK!", gc.matchStreak);
            }
            gc.gameOverStreakText.text = string.Format("{0} Streak", gc.maxMatchStreak);

            if (gc.scoreDirty)
            {
                int score     = gc.Score;
                int highScore = PlayerPrefs.GetInt("highScore");
                if (score > highScore)
                {
                    PlayerPrefs.SetInt("highScore", score);
                    highScore = score;
                }
                if (gc.Score == 0)
                {
                    this._internalScore = 0;
                }
                gc.HandleCoroutine(LerpToScore());

                gc.pauseScoreText.text     = string.Format("{0}", gc.Score);
                gc.pauseHighScoreText.text = string.Format("{0}", highScore);

                gc.mainMenuHighScoreText.text = string.Format("{0}", highScore);
            }

            if (gc.livesMode && gc.livesDirty)
            {
                for (int i = 0; i < gc.livesContainer.transform.childCount; i++)
                {
                    gc.livesContainer.transform.GetChild(i).gameObject.SetActive(i < gc.Lives);
                }
            }
            gc.scoreDirty = false;
            gc.livesDirty = false;
        }

        if (gc.timeMode)
        {
            int min = ((int)gc.totalTime) / 60;
            int sec = ((int)gc.totalTime) % 60;
            gc.timerText.text = string.Format("{0:D2}:{1:D2}", Mathf.Max(min, 0), Mathf.Max(sec, 0));
            gc.totalTime     -= Time.deltaTime;
        }
    }
Ejemplo n.º 17
0
 private void LocalTeleport(int MoveNumber, ScriptEventData data)
 {
     Log.Write("MoveNumber: " + MoveNumber);
     LastCameraMan = CameraMan;
     foreach (AgentPrivate agent in ScenePrivate.GetAgents())
     {
         Log.Write(agent.AgentInfo.Name);
         if (agent.AgentInfo.Name == CameraMan)
         {
             Log.Write("Camaeraman found");
             ObjectPrivate objectPrivate = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);
             if (objectPrivate != null)
             {
                 AnimationComponent anim = null;
                 if (objectPrivate.TryGetFirstComponent(out anim))
                 {
                     RigidBody.SetPosition(MoveVector[MoveNumber]);
                     Wait(TimeSpan.FromSeconds(0.05));
                     anim.SetPosition(MoveVector[MoveNumber]);
                     Wait(TimeSpan.FromSeconds(0.05));
                     Quaternion rotation = Quaternion.FromEulerAngles(Mathf.RadiansPerDegree * RotateVector[MoveNumber]);
                     RigidBody.SetOrientation(rotation);
                     //PlayMovement(MoveNumber, data);
                 }
             }
         }
     }
 }
Ejemplo n.º 18
0
        public override void Start()
        {
            animation = Entity.Get <AnimationComponent>();

            // Set the default animation
            latestAnimation = animation.Play("Idle");
        }
Ejemplo n.º 19
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // Setup render pipeline
            RenderSystem.Pipeline.Renderers.Add(new CameraSetter(Services));
            RenderSystem.Pipeline.Renderers.Add(new RenderTargetSetter(Services)
            {
                ClearColor = Color.Blue, RenderTarget = GraphicsDevice.BackBuffer, DepthStencil = GraphicsDevice.DepthStencilBuffer
            });
            RenderSystem.Pipeline.Renderers.Add(new ModelRenderer(Services, "Default"));

            // Load asset
            var dudeEntity = Asset.Load <Entity>("AnimatedModel");

            animationComponent = dudeEntity.Get(AnimationComponent.Key);

            Entities.Add(dudeEntity);

            // Setup view
            RenderSystem.Pipeline.Parameters.Set(TransformationKeys.View, Matrix.LookAtRH(new Vector3(200, 0.0f, 100f), new Vector3(0f, 0f, 80.0f), Vector3.UnitZ));
            RenderSystem.Pipeline.Parameters.Set(TransformationKeys.Projection, Matrix.PerspectiveFovRH((float)Math.PI * 0.4f, 1.3f, 1.0f, 1000.0f));

            animationComponent.Play("Run");
            walkAnimation = animationComponent.PlayingAnimations[0];
        }
Ejemplo n.º 20
0
        public override void onAddedToScene()
        {
            // TODO - this should happen automatically
            scale = new Vector2(5, 5);

            var gameScene           = (HandyScene)scene;
            var animationDefinition = gameScene.AnimationDefinitions[AsepriteFiles.SPACEMAN_SHIELD];

            var sprite = new AnimatableSprite(animationDefinition.SpriteDefinition.Subtextures);

            sprite.renderLayer = RenderLayers.PRIMARY;

            var animation = new AnimationComponent(sprite, animationDefinition, SpacemanAnimations.SHIELD);

            var collider = new BoxCollider(5 * 1.5f, 5 * 5.5f);

            collider.localOffset = new Vector2(5, 0);
            Flags.setFlagExclusive(ref collider.physicsLayer, PhysicsLayers.BACK_WALLS);
            Flags.setFlag(ref collider.collidesWithLayers, PhysicsLayers.BALL);

            var events = new EventComponent();

            events.SetTriggers(_triggers);

            addComponent(sprite);
            addComponent(animation);
            addComponent(events);
            addComponent(collider);

            position = new Vector2(position.X + 5 * 15, position.Y);
        }
Ejemplo n.º 21
0
    private void AddDoor(Vector3 location)
    {
        int id = Game.EntityManager.CreateEntity();

        var formComp = new FormComponent();

        formComp.InitComponent(id, location, "Door001", "");
        Game.EntityManager.AddComponent(id, formComp);

        var openComp = new OpenComponent();

        openComp.InitComponent(null);
        Game.EntityManager.AddComponent(id, openComp);

        var animComp = new AnimationComponent();

        animComp.InitComponent(null);
        animComp.Animations.Add(new AnimationSystem.AnimationData()
        {
            EntityID = id, Name = "DoorClose90", Sound = "DoorClose001", DisablePhysics = true, TriggerEvent = RPGGameEvent.Menu_Close
        });
        animComp.Animations.Add(new AnimationSystem.AnimationData()
        {
            EntityID = id, Name = "DoorOpen90", Sound = "DoorOpen001", DisablePhysics = true, TriggerEvent = RPGGameEvent.Menu_Open
        });
        Game.EntityManager.AddComponent(id, animComp);

        //// Theoretically, this should work if the attribute table is set in the blueprints. Untested
        //var cursorComp = new CursorComponent();
        //cursorComp.InitComponent(null);
        //Game.EntityManager.AddComponent(id, cursorComp);
    }
Ejemplo n.º 22
0
        public static int CreatePlayerBodyLegs(GraphicsDevice gd, Vector3 scale)
        {
            int x = -400;
            int y = 200;
            int z = 120;

            int body          = CreateCube(gd, "grass", new Vector3(x, y, z), new Vector3(-5, -5, -5), new Vector3(5, 5, 5), scale, null, "Body");
            int head          = CreateCube(gd, "checkerboard", new Vector3(0, 5, 0), new Vector3(-3, 0, -3), new Vector3(3, 6, 3), body, "Head");
            int rightLegJoint = CreateCube(gd, "checkerboard", new Vector3(5, 1, 0), new Vector3(0, 0, 0), new Vector3(1, 1, 1), body, "RightLegJoint");
            int leftLegJoint  = CreateCube(gd, "checkerboard", new Vector3(-5, 1, 0), new Vector3(-1, 0, 0), new Vector3(0, 1, 1), body, "LeftLegJoint");
            int rightLeg      = CreateCube(gd, "grass", new Vector3(0, -9, 0), new Vector3(1, 0, 0), new Vector3(2, 10, 2), rightLegJoint, "RightLeg");
            int leftLeg       = CreateCube(gd, "grass", new Vector3(0, -9, 0), new Vector3(-1, 0, 0), new Vector3(-2, 10, 2), leftLegJoint, "LeftLeg");
            int rightArmJoint = CreateCube(gd, "checkerboard", new Vector3(3, -6, 0), new Vector3(0, 0, 0), new Vector3(1, 1, 1), body, "RightArmJoint");
            int leftArmJoint  = CreateCube(gd, "checkerboard", new Vector3(-3, -6, 0), new Vector3(0, 0, 0), new Vector3(1, 1, 1), body, "LeftArmJoint");
            int rightArm      = CreateCube(gd, "grass", new Vector3(0, -9, 0), new Vector3(1, 0, 0), new Vector3(2, 10, 2), rightArmJoint, "RightArm");
            int leftArm       = CreateCube(gd, "grass", new Vector3(0, -9, 0), new Vector3(-1, 0, 0), new Vector3(-2, 10, 2), leftArmJoint, "LeftArm");

            AnimationComponent aComp = new AnimationComponent()
            {
                Animate = true
            };

            ComponentManager.GetInstance().AddComponentsToEntity(body, aComp);
            return(body);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// update function, is used for handling the update process for the animations.
        /// </summary>
        /// <param name="gameTime">takes a GameTime object as a parameter inorder to check if it should change the current frame</param>
        public void update(GameTime gameTime)
        {
            List <int> enteties = ComponentManager.Instance.GetAllEntitiesWithComponentType <AnimationComponent>();

            if (enteties != null)
            {
                foreach (int entity in enteties)
                {
                    AnimationComponent anim = ComponentManager.Instance.GetEntityComponent <AnimationComponent>(entity);


                    anim.timeElapsedSinceLastFrame += gameTime.ElapsedGameTime.TotalSeconds;

                    if (anim.timePerFrame < anim.timeElapsedSinceLastFrame)
                    {
                        anim.timeElapsedSinceLastFrame = 0;
                        anim.currentFrame++;

                        if (anim.currentFrame > anim.getAnimationLength() && anim.oneTime == false)
                        {
                            anim.currentFrame = 0;
                        }
                        else if (anim.currentFrame > anim.getAnimationLength() && anim.oneTime == true)
                        {
                            anim.currentFrame = anim.getAnimationLength();
                        }
                        anim.setNewPosRectangle(anim.currentFrame);
                    }
                }
            }
        }
Ejemplo n.º 24
0
    private void SubscribeToHotkey(SessionId userId)
    {
        AgentPrivate agent = ScenePrivate.FindAgent(userId);

        // Lookup the scene object for this agent
        ObjectPrivate agentObejct = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);

        if (agentObejct == null)
        {
            Log.Write($"Unable to find a ObjectPrivate component for user {userId}");
            return;
        }

        // Lookup the animation component. There should be just one, so grab the first
        AnimationComponent animationComponent = null;

        if (!agentObejct.TryGetFirstComponent(out animationComponent))
        {
            Log.Write($"Unable to find an animation component on user {userId}");
            return;
        }

        // Listen for a key press. Since the agent will be teleporting away, do no request a persistent subscription
        animationComponent.Subscribe(TeleportHotkey, TeleportToNext, false);
    }
Ejemplo n.º 25
0
 private void PauseAt(float normalizedTime)
 {
     AnimationComponent.Play(Clip.name);
     AnimationState.speed          = 0;
     AnimationState.normalizedTime = normalizedTime;
     RequestToStopAnimation();
 }
Ejemplo n.º 26
0
 void RequestToStopAnimation()
 {
     if (!isPrepared)
     {
         AnimationComponent.Stop(Clip.name);
     }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerEntity"/> class.
        /// </summary>
        /// <param name="hide">if set to <c>true</c> [hide].</param>
        public PlayerEntity(bool hide = false) : base()
        {
            this.CurrentState = CharacterState.Standing;
            this.Velocity     = new Vector2();


            myAnimationComponent = new AnimationComponent("Idle", this,
                                                          framNumber,
                                                          playSpeed,
                                                          Names,
                                                          RenderManager.zombieAnimatedAttribute.Width
                                                          , RenderManager.zombieAnimatedAttribute.Height
                                                          , RenderManager.zombieAnimatedAttribute.Scale);

            // Hand Logic
            //HandChain = new ThrowAbleEntity(this.Position + HandEntry.HndPositionOffSet, this);
            _hand = new HandEntity(this);

            // Load Content
            var texture = myAnimationComponent.LoadContent();

            this.Hide = hide;
            Width     = 32f;
            Height    = 32f;

            this.CollisionComponent = new BoxColliderComponent(this, this.Width, this.Height, CollisionLayers.Player);

            this.CurrentState = CharacterState.Airbourne;
        }
Ejemplo n.º 28
0
        public void ToItem(AGSSerializationContext context, IObject obj)
        {
            obj.ResetScale(InitialWidth, InitialHeight);
            var image = Image.ToItem(context);

            if (image != null)
            {
                obj.Image = image;
                obj.Scale = new PointF(ScaleX, ScaleY);
            }
            obj.Location = new AGSLocation(Location.Item1, Location.Item2, Location.Item3);
            obj.Pivot    = new PointF(Pivot.Item1, Pivot.Item2);
            obj.Angle    = Angle;
            obj.Tint     = Color.FromHexa(Tint);

            obj.IsPixelPerfect = IsPixelPerfect;
            AnimationComponent.ToItem(context, obj);
            obj.RenderLayer = RenderLayer.ToItem(context);
            obj.Properties.CopyFrom(Properties.ToItem(context));
            obj.Enabled           = Enabled;
            obj.DisplayName       = DisplayName;
            obj.IgnoreViewport    = IgnoreViewport;
            obj.IgnoreScalingArea = IgnoreScalingArea;
            obj.Visible           = Visible;

            if (Parent != null)
            {
                var parent = Parent.ToItem(context);
                obj.TreeNode.SetParent(parent.TreeNode);
            }
        }
Ejemplo n.º 29
0
    void Start()
    {
        isCoroutineRunning = false;
        isModelScene       = false;
        currentCanvasState = 0;
        _animator          = GetComponent <Animator>();
        component          = new AnimationComponent();

        hide_back_Button();
        hide_reload_btn();
        hide_info_Button();
        hide_screenShot_btn();
        isFirstSession = SaveManager.Instance.session_state.isFirstEnter;

        if (!isFirstSession)
        {
            show_info_Button();
        }
        startGeneratePlane();

        bool isX = UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhoneX;

        if (isX)
        {
            about_map_Panel.transform.position    += new Vector3(0, -120f, 0);
            about_pins_Panel.transform.position   += new Vector3(0, -120f, 0);
            find_surface_Panel.transform.position += new Vector3(0, -120f, 0);
        }
    }
Ejemplo n.º 30
0
        public TriggerEntity(string tileName, Vector2 position, Tags type, bool isAnimation = false) : base()
        {
            this._isAnimation = isAnimation;
            if (isAnimation)
            {
                animationComponent = new AnimationComponent(tileName, this,
                                                            new int[] { 6 },
                                                            new int[] { 60 },
                                                            new string[] { tileName },
                                                            32
                                                            , 32
                                                            , new Vector2(1, 1));
                animationComponent.LoadContent();
            }
            else
            {
                renderComponent = new RenderComponent(tileName, this);
                this.renderComponent.LoadContent();
            }



            this.Position = position;
            Width         = 32;
            Height        = 32;

            _isAnimation      = isAnimation;
            _alreadyTriggered = false;

            this.CollisionComponent = new BoxColliderComponent(this, Width, Height, Layers.Static, type);
        }
Ejemplo n.º 31
0
        public void AnimationComponentUpdateTest()
        {
            List<Texture2D> textures = new List<Texture2D>();
            textures.Add(null);
            textures.Add(null);
            AnimationComponent comp = new AnimationComponent(textures, 50, 50, 50, 50, 1);

            comp.Update(1);

            Assert.Equal(comp.animationComplete(), true);
        }
Ejemplo n.º 32
0
 private void SetRunningAnimation(AnimationComponent animationComponent, string name)
 {
     if (animationComponent.Animations.ContainsKey(name)){
         if (animationComponent.CurrentAnimationId != name){
             var animation = animationComponent.Animations[name];
             animation.CurrentFrameIndex = 0;
             animationComponent.Elapsed = 0.0f;
             animationComponent.CurrentAnimationId = name;
         }
     }
     else{
         animationComponent.CurrentAnimationId = string.Empty;
     }
 }
Ejemplo n.º 33
0
        private void UpdateAnimation(float dt, AnimationComponent animationComponent)
        {
            var animation = animationComponent.Animations[animationComponent.CurrentAnimationId];

            if (animation.AnimationFrames.Count == 0) return;

            animationComponent.Elapsed += dt;
            if (!(animationComponent.Elapsed > animation.CurrentFrame.Duration)) return;

            animation.CurrentFrameIndex++;
            if (animation.CurrentFrameIndex >= animation.AnimationFrames.Count)
                animation.CurrentFrameIndex = 0;

            animationComponent.Elapsed = 0;
        }
Ejemplo n.º 34
0
        public Player(Point topLeft)
            : base(new Rectangle(topLeft.X, topLeft.Y, NINJA_WIDTH, NINJA_HEIGHT), NinjaTexture)
        {
            velocity = Vector2.Zero;
            NinjaMovement = NinjaRunSpeed;

            ninjaLifeState = LifeState.Alive;
            hasGravity = true;
            actionState = NinjaActionState.Standing;
            resizeRect = ScreenCoordinateDrawFrame();

            ResetWarpAnimation();

            running = new AnimationComponent(RunTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            jumping = new AnimationComponent(JumpTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 2);
            airborne = new AnimationComponent(AirborneTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            wallJumping = new AnimationComponent(WallJumpTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 2);
            wallClimbing = new AnimationComponent(WallClimbTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            Rolling = new AnimationComponent(RollTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            wallSliding = new AnimationComponent(WallSlideTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            ItemThrowing = new AnimationComponent(ItemThrowTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            SwordSwinging = new AnimationComponent(SwordSwingTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            SwordRunning = new AnimationComponent(SwordRunTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            ShurikenRunning= new AnimationComponent(ShurikenRunTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            VictoryPose= new AnimationComponent(VictoryTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            SquishDying= new AnimationComponent(SquishDeathTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            FallDying= new AnimationComponent(FallDeathTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            FireDying= new AnimationComponent(FireDeathTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            ExplodeDying = new AnimationComponent(ExplodeDeathTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
            VillainDying = new AnimationComponent(VillainDeathTextures, drawRect.Left, drawRect.Top, NINJA_WIDTH, NINJA_HEIGHT, 1);
        }
Ejemplo n.º 35
0
        public Npc(string mapName, string name, int x, int y, int width, int height, bool up, bool down, bool left, bool right,
            string spritePath, string portraitPath, bool patrolNone, bool patrolUpDown, bool patrolLeftRight,
            bool patrolBox, int patrolX, int patrolY, int patrolWidth, int patrolHeight, float speed, Game1 game,
            string dialoguePath, string keyName, string secondDialogue, string thirdDialogue)
        {
            position = new Rectangle(x, y, 50, 71);
            this.name = name;
            this.mapName = mapName;
            this.up = up;
            this.down = down;
            this.left = left;
            this.right = right;
            vulnerable = true;
            minDamage = 2;
            maxDamage = 15;
            patrolRect = new Rectangle(patrolX, patrolY, patrolWidth, patrolHeight);
            aTexture = game.Content.Load<Texture2D>(@"Npc\A");
            aPosition = new Rectangle(0, 0, aTexture.Width, aTexture.Height);
            health = 200;
            maxHealth = health;
            this.speed = speed;
            this.game = game;

            if (name != "Informer")
            {
                dialogue = new Dialogue(game.Content.Load<Texture2D>(@"npc\portrait\" + portraitPath), Game1.textBox, game, Game1.spriteFont, dialoguePath, name);
                walkSprite = game.Content.Load<Texture2D>(@"npc\sprite\" + spritePath);
            }

            debugTile = game.Content.Load<Texture2D>(@"Player\emptySlot");
            healthTexture = game.Content.Load<Texture2D>(@"Game\health100");
            aColor = Color.White;
            DEATH = 8;
            if (name == "Celine")
            {
                animation = new AnimationComponent(2, 9, 50, 72, 175, Microsoft.Xna.Framework.Point.Zero);
                position.Height = 72;
                sword = new Game.Items.Sword("cockiri", 17, 27);//3, 17
                waypoint = new WaypointManager(name, "Map3_B", 2);
            }
            else if (name == "Headmaster")
            {
                animation = new AnimationComponent(2, 9, 50, 127, 175, Microsoft.Xna.Framework.Point.Zero);
                vulnerable = false;
                position.Y -= 60;
                position.Height = 127;

                waypoint = new WaypointManager(name, "Map3_B", 3);
            }
            else if (name == "Lamia")
            {
                animation = new AnimationComponent(2, 4, 100, 76, 175, Microsoft.Xna.Framework.Point.Zero);
                position.Y -= 64;
                position.Height = 64;
                position.Width = 84;
            }
            else if (name == "Laune")
            {
                animation = new AnimationComponent(3, 11, 50, 75, 175, Microsoft.Xna.Framework.Point.Zero);

            }
            else if (name == "Informer")
            {
                if (spritePath == @"Player\maleSheet")
                {
                    animation = new AnimationComponent(4, 13, 50, 70, 150, Microsoft.Xna.Framework.Point.Zero);
                }
                else
                {
                    animation = new AnimationComponent(4, 4, 41, 70, 150, Microsoft.Xna.Framework.Point.Zero);
                }
            }
            else if (name == "Sylian")
            {
                quest = new Quest(Game1.ribbon.item, this.name);
                animation = new AnimationComponent(2, 4, 50, 71, 175, Microsoft.Xna.Framework.Point.Zero);
            }
            else
            {
                animation = new AnimationComponent(2, 4, 50, 71, 175, Microsoft.Xna.Framework.Point.Zero);
            }

            mob = false;

            dialogue.dialogueManager.ReachedExit += ExitedDialogue;
            if (keyName != "nokey")
            {
                key = new Key(Rectangle.Empty, keyName, game.keyTexture, this.mapName, game);
            }

            this.secondDialogue = secondDialogue;
            this.thirdDialogue = thirdDialogue;
        }
Ejemplo n.º 36
0
        public static void LoadContent(ContentManager Content, EnemyType type)
        {
            if (StandingTextures == null)
            {
                StandingTextures = new Texture2D[(int)EnemyType.NumberOfEnemies];
                ProjectileTextures = new Texture2D[1];

                RunTextures = new List<Texture2D>[(int)EnemyType.NumberOfEnemies];
                running = new AnimationComponent[(int)EnemyType.NumberOfEnemies];

                AttackTextures = new List<Texture2D>[(int)EnemyType.NumberOfEnemies];
                attacking = new AnimationComponent[(int)EnemyType.NumberOfEnemies];

                for (int i = 0; i < TextureLoaded.Length; ++i)
                    TextureLoaded[i] = false;
            }

            switch (type)
            {
                case EnemyType.Goon:
                    if (TextureLoaded[0]) return;
                    StandingTextures[0] = Content.Load<Texture2D>("Enemies/goonMoveLeft1");
                    RunTextures[0] = new List<Texture2D>();
                    AttackTextures[0] = new List<Texture2D>();

                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft1"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft2"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft3"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft4"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft5"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft6"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft7"));
                    RunTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft8"));
                    running[0] = new AnimationComponent(RunTextures[0], 0, 0, 100, 160, 2);
                    AttackTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft1"));
                    AttackTextures[0].Add(Content.Load<Texture2D>("Enemies/goonMoveLeft1"));
                    attacking[0] = new AnimationComponent(AttackTextures[0], 0, 0, 100, 160, 1);
                    TextureLoaded[0] = true;
                    break;
                case EnemyType.KnifeArtist:
                    if (TextureLoaded[1]) return;
                    StandingTextures[1] = Content.Load<Texture2D>("Enemies/knife artist 1");
                    ProjectileTextures[0] = Content.Load<Texture2D>("ninjastar");
                    RunTextures[1] = new List<Texture2D>();
                    AttackTextures[1] = new List<Texture2D>();

                    RunTextures[1].Add(Content.Load<Texture2D>("Enemies/knife artist 1"));
                    RunTextures[1].Add(Content.Load<Texture2D>("Enemies/knife artist 2"));
                    RunTextures[1].Add(Content.Load<Texture2D>("Enemies/knife artist 3"));
                    RunTextures[1].Add(Content.Load<Texture2D>("Enemies/knife artist 4"));
                    running[1] = new AnimationComponent(RunTextures[1], 0, 0, 100, 160, 2);
                    AttackTextures[1].Add(Content.Load<Texture2D>("Enemies/knife artist 5"));
                    AttackTextures[1].Add(Content.Load<Texture2D>("Enemies/knife artist 6"));
                    attacking[1] = new AnimationComponent(AttackTextures[1], 0, 0, 100, 160, 1);
                    TextureLoaded[1] = true;
                    break;
                case EnemyType.Bat:
                    if (TextureLoaded[2]) return;
                    StandingTextures[2] = Content.Load<Texture2D>("Enemies/bat1");
                    ProjectileTextures[0] = Content.Load<Texture2D>("ninjastar");
                    RunTextures[2] = new List<Texture2D>();
                    AttackTextures[2] = new List<Texture2D>();

                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat1"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat2"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat3"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat4"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat5"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat6"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat7"));
                    RunTextures[2].Add(Content.Load<Texture2D>("Enemies/bat8"));

                    running[2] = new AnimationComponent(RunTextures[2], 0, 0, 100, 160, 2);
                    AttackTextures[2].Add(Content.Load<Texture2D>("Enemies/bat1"));
                    AttackTextures[2].Add(Content.Load<Texture2D>("Enemies/bat1"));
                    attacking[2] = new AnimationComponent(AttackTextures[2], 0, 0, 100, 160, 1);
                    TextureLoaded[2] = true;
                    break;
                case EnemyType.Rat:
                    if (TextureLoaded[3]) return;
                    StandingTextures[3] = Content.Load<Texture2D>("Enemies/rat1");
                    ProjectileTextures[0] = Content.Load<Texture2D>("ninjastar");
                    RunTextures[3] = new List<Texture2D>();
                    AttackTextures[3] = new List<Texture2D>();

                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat1"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat2"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat3"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat4"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat5"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat6"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat7"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat8"));
                    RunTextures[3].Add(Content.Load<Texture2D>("Enemies/rat9"));
                    running[3] = new AnimationComponent(RunTextures[3], 0, 0, 100, 160, 2);
                    AttackTextures[3].Add(Content.Load<Texture2D>("Enemies/rat1"));
                    AttackTextures[3].Add(Content.Load<Texture2D>("Enemies/rat1"));
                    attacking[3] = new AnimationComponent(AttackTextures[3], 0, 0, 100, 160, 1);
                    TextureLoaded[3] = true;
                    break;
            }
        }
Ejemplo n.º 37
0
 public Boss(Rectangle position, Game1 game, string map)
 {
     this.position = position;
     this.map = map;
     healthTexture = game.Content.Load<Texture2D>(@"Game\health100");
     healthPos = new Rectangle();
     texture = game.Content.Load<Texture2D>(@"Npc\sprite\Cybot");
     targetTexture = game.Content.Load<Texture2D>(@"Game\target");
     angle = Math.Atan2(Game1.character.bossTarget.Y - position.Y, Game1.character.bossTarget.X + 16 - position.X);
     robot = new Npc(position.X - 64, position.Y, 64, 64, game.Content.Load<Texture2D>(@"robot"), game, this.map, 0, false, 10, 0, 0, 0, false);
     animation = new AnimationComponent(2, 8, 54, 70, 175, Microsoft.Xna.Framework.Point.Zero);
 }
Ejemplo n.º 38
0
 public Npc(int x, int y, int width, int height, Texture2D walkSprite, Game1 game, string mapName,
     float timerMod, bool attackPlayer, int health, int minDamage, int maxDamage, int hitChance, bool vulnerable)
 {
     this.mapName = mapName;
     position.X = x;
     position.Y = y - 128;
     position.Width = width;
     position.Height = height;
     this.walkSprite = walkSprite;
     this.attackPlayer = attackPlayer;
     this.health = health;
     this.minDamage = minDamage;
     this.maxDamage = maxDamage;
     this.hitChance = hitChance;
     this.vulnerable = vulnerable;
     this.speed = 1;
     pathTimerMod = timerMod;
     healthTexture = game.Content.Load<Texture2D>(@"Game\health100");
     debugTile = game.Content.Load<Texture2D>(@"Player\emptySlot");
     maxHealth = health;
     MOBPATHTIMER = rand.Next(2000, 10000) * timerMod;
     mob = true;
     animation = new AnimationComponent(3, 13, 50, 74, 175, Microsoft.Xna.Framework.Point.Zero);
     deathSprite = game.Content.Load<Texture2D>(@"Npc\deathSprite");
     key = null;
     DEATH = 12;
 }
Ejemplo n.º 39
0
        public Player(Point topLeft)
            : base(new Rectangle(topLeft.X, topLeft.Y, NINJA_WIDTH, NINJA_HEIGHT), NinjaTexture)
        {
            velocity = Vector2.Zero;
            NinjaMovement = NinjaRunSpeed;

            ninjaLifeState = LifeState.Alive;
            hasGravity = true;
            actionState = NinjaActionState.Standing;

            running = new AnimationComponent(RunTextures, GetDrawFrameX(), GetDrawFrameY(), NINJA_WIDTH, NINJA_HEIGHT);
            jumping = new AnimationComponent(JumpTextures, GetDrawFrameX(), GetDrawFrameY(), NINJA_WIDTH, NINJA_HEIGHT);
            airborne = new AnimationComponent(AirborneTextures, GetDrawFrameX(), GetDrawFrameY(), NINJA_WIDTH, NINJA_HEIGHT);
            //wallJumping = new AnimationComponent(WallJumpTextures, GetDrawFrameX(), GetDrawFrameY(), NINJA_IMAGE_X, NINJA_IMAGE_Y);
            //wallClimbing = new AnimationComponent(WallClimbTextures, GetDrawFrameX(), GetDrawFrameY(), NINJA_IMAGE_X, NINJA_IMAGE_Y);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Load animations based on the current enemy
        /// </summary>
        /// <param name="Content">Content manager to load from.</param>
        public void LoadAnimations(ContentManager Content)
        {
            //Sorry bro-grammers, this is our best bet until we can read these in via the .xml file
            if (EnemyName.Equals("Enemies/Muscle-Goon"))
            {
                RunTextures.Add(Content.Load<Texture2D>("Enemies/Muscle-Goon 1"));
                RunTextures.Add(Content.Load<Texture2D>("Enemies/Muscle-Goon 2"));
                RunTextures.Add(Content.Load<Texture2D>("Enemies/Muscle-Goon 3"));
                RunTextures.Add(Content.Load<Texture2D>("Enemies/Muscle-Goon 4"));
                running = new AnimationComponent(RunTextures, 0, 0, 100, 160);
                AttackTextures.Add(Content.Load<Texture2D>("Enemies/Muscle-Goon 5"));
                AttackTextures.Add(Content.Load<Texture2D>("Enemies/Muscle-Goon 6"));
                attacking = new AnimationComponent(AttackTextures, 0, 0, 100, 160);

                projectileTexture = Content.Load<Texture2D>("shuriken slide 1");
            }
            else if (EnemyName.Equals("Enemies/knife artist 1"))
            {
                RunTextures.Add(Content.Load<Texture2D>("Enemies/knife artist 1"));
                RunTextures.Add(Content.Load<Texture2D>("Enemies/knife artist 2"));
                RunTextures.Add(Content.Load<Texture2D>("Enemies/knife artist 3"));
                RunTextures.Add(Content.Load<Texture2D>("Enemies/knife artist 4"));
                running = new AnimationComponent(RunTextures, 0, 0, 100, 160);
                AttackTextures.Add(Content.Load<Texture2D>("Enemies/knife artist 5"));
                AttackTextures.Add(Content.Load<Texture2D>("Enemies/knife artist 6"));
                attacking = new AnimationComponent(AttackTextures, 0, 0, 100, 160);
                projectileTexture = Content.Load<Texture2D>("shuriken slide 1");

            }
        }
        public cCharacter(Game1 game, string gender)
        {
            health = 100;
            speed = 4;
            maxHealth = health;
            healthBar = game.Content.Load<Texture2D>(@"Game\Hp bar");
            this.gender = gender;

            #region Textures
            debugTexture = game.Content.Load<Texture2D>(@"Game\blackness");
            if (gender == "male")
            {
                spriteSheet = game.Content.Load<Texture2D>("Player/Sprite/Male/male");
                animation = new AnimationComponent(4, 8, 53, 70, 150, Point.Zero);
            }
            if (gender == "female")
            {
                spriteSheet = game.Content.Load<Texture2D>("Player/Sprite/Female/female");
                animation = new AnimationComponent(4, 8, 41, 70, 150, Point.Zero);
            }

            shadowBlob = game.Content.Load<Texture2D>("player/shadowTex");
            healthTexture = game.Content.Load<Texture2D>(@"Game\health100");
            #endregion

            #region Rectangles and Vectors
            if (gender == "male")
            {
                positionRectangle = new Rectangle(640, 640, 59, 64);
            }
            if (gender == "female")
            {
                positionRectangle = new Rectangle(640, 640, 50, 64);
            }
            position.X = positionRectangle.X;
            position.Y = positionRectangle.Y;
            interactRect = new Rectangle(positionRectangle.X - (positionRectangle.Width / 2), positionRectangle.Y - (positionRectangle.Height / 2), positionRectangle.Width * 2, positionRectangle.Height * 2);

            attackRectangle = new Rectangle();
            warpRectangle = new Rectangle();
            healthPos = new Rectangle();
            #endregion

            hpColor = new Color(200, 200, 200, 255);

            inventory = new Inventory(game);

            emitter = new ParticleSystemEmitter(game);
            Game1.particleSystem.emitters.Add(emitter);
            bossTarget = new Vector2(-128, -128);
        }
Ejemplo n.º 42
0
        public Command(Point center, CommandType Type)
            : base(new Rectangle(center.X - halfCommand, center.Y - halfCommand, commandSize, commandSize), textures[(int)Type])
        {
            type = Type;
            ConnectedPlatforms = new LinkedList<Platform>();

            selected = false;

            List<Texture2D> myIcons;
            switch (type)
            {
                case CommandType.MoveLeft:
                    myIcons = RunLeftIcon;
                    break;
                case CommandType.MoveRight:
                    myIcons = RunRightIcon;
                    break;
                case CommandType.Jump:
                    myIcons = JumpIcon;
                    break;
                case CommandType.WallJump:
                    myIcons = WallJumpIcon;
                    break;
                case CommandType.WallSlide:
                    myIcons = WallSlideIcon;
                    break;
                case CommandType.LedgeClimb:
                    myIcons = LedgeClimbIcon;
                    break;
                case CommandType.ObjectThrow:
                    myIcons = UseItemIcon;
                    actionTarget = new CommandTarget(new Point(center.X + 200, center.Y));
                    break;
                default:
                    throw new Exception("Invalid command type encountered in Command.Command()");
            }

            myIconAnimation = new AnimationComponent(myIcons, drawRect.Left, drawRect.Top, drawRect.Width, drawRect.Height, 1);

            setcharge = 1;
            charges = 1;
        }
Ejemplo n.º 43
0
    void Awake()
    {
        _healthcomponent = GetComponent<HealthComponent>();
        _movement = GetComponent<MovementComponent>();
        _animComponent = GetComponent<AnimationComponent>();

        float random = Random.Range ( -25f, 25f );
        _movement.BASESPEED += random;
    }