Example #1
0
        internal void _drawEntityOnScreen(GEntity t)
        {
            int sx = t.iX, sy = t.iY;

            t.X = 0;
            t.Y = 0;
            GBitmap g = new GBitmap(GTile.WIDTH, GTile.HEIGHT);

            t.Render(g);
            t.X            = sx;
            t.Y            = sy;
            g.ScreenWidth  = (int)(DisplayWidth - sx + _tileOffsetX * GTile.HEIGHT);
            g.ScreenHeight = (int)(DisplayHeight - sy + _tileOffsetY * GTile.WIDTH);

            if (g.ScreenWidth > GTile.WIDTH)
            {
                g.ScreenWidth = GTile.WIDTH;
            }
            if (g.ScreenHeight > GTile.HEIGHT)
            {
                g.ScreenHeight = GTile.HEIGHT;
            }
            int x = sx + OffsetX - _tileOffsetX * GTile.WIDTH;
            int y = sy + OffsetY - _tileOffsetY * GTile.HEIGHT;

            if (g.ScreenHeight < 0 || g.ScreenWidth < 0 || x < OffsetX || y < OffsetY)
            {
                return;
            }
            Screen.Blit(g.GetClippedImage(), x, y);
        }
Example #2
0
        private int[] GetFutureBonusTiles()
        {
            ++BonusGenerationAttempts;

            if (BonusGenerationAttempts > 10)
            {
                return(new int[] { 0, 0 });
            }

            int FutureXt = Program.Rand.Next(CurrentLevelWidth);
            int FutureYt = Program.Rand.Next(CurrentLevelHeight);

            GEntity FutureBonusPlace = new GEntity(FutureXt * GTile.WIDTH, FutureYt * GTile.HEIGHT, 30, 30);
            GEntity Tile             = GetTile(FutureXt, FutureYt);

            int ie = GetIntersectingEntities(FutureBonusPlace).Count;
            int ip = GetIntersectingPlayers(FutureBonusPlace).Count;
            int ib = GetIntersectingBonuses(FutureBonusPlace).Count;

            if (Tile != null && Tile.CanPass && ie == 0 && ib == 0 && ip == 0)
            {
                BonusGenerationAttempts = 0;
                return(new int[] { FutureXt, FutureYt });
            }
            else
            {
                return(GetFutureBonusTiles());
            }
        }
Example #3
0
    void OnTriggerEnter(Collider c)
    {
        if (!m_active || !m_damage_on_enter)
        {
            return;
        }

        GEntity target = c.gameObject.GetComponent <GEntity>();

        if (target != null && (target.m_team_id != m_owner.m_team_id || friendly_fire))
        {
            target.Damage(m_damage);
        }

        //Destroy on collision with anything but the owner, if destroy_on_enter.
        if (m_destroy_on_enter && (target == null || target != m_owner))
        {
            if (m_hit_particle)
            {
                Instantiate(m_hit_particle, transform.position, Quaternion.identity);
            }

            Destroy(gameObject);
        }
    }
Example #4
0
 public static void AddEntity(GEntity Entity)
 {
     lock (Entities)
     {
         Entities.Add(Entity);
     }
 }
Example #5
0
    void AIFollow(GEntity target)
    {
        GTeam team = m_entity.m_controller.GetTeam(m_entity.m_team_id);

        if (team == null || team.GetLeader() == null || team.m_waypoint_set == false)
        {
            return;
        }

        Vector3 waypoint          = team.GetLeader().transform.position + team.GetOrbitPosition(m_entity.m_team_member_id);
        float   waypoint_distance = Vector3.Distance(transform.position, waypoint);
        float   target_distance   = Vector3.Distance(transform.position, team.GetLeader().transform.position);

        if (!m_entity.m_combatant.IsUsingActionThatBlocksMovement() &&
            (target_distance > m_combat_range.max * 2 && waypoint_distance > .8f) &&
            !m_at_ideal_range)
        {
            Vector3 dir = waypoint - transform.position;
            Vector2 target_direction = new Vector2(dir.x, dir.z);
            m_entity.m_mobile.Move(m_entity.m_move_speed * 2, target_direction);
        }
        else if (!m_entity.m_combatant.IsUsingActionThatBlocksMovement() &&
                 (target_distance > m_combat_range.min || waypoint_distance > .8f) &&
                 !m_at_ideal_range)
        {
            Vector3 dir = waypoint - transform.position;
            Vector2 target_direction = new Vector2(dir.x, dir.z);
            m_entity.m_mobile.Move(m_entity.m_move_speed, target_direction);
        }
        m_follow_point_reached = waypoint_distance <= .8f;
    }
Example #6
0
 void Start()
 {
     m_entity = GetComponent <GEntity>();
     m_canvas = GameObject.Find("Canvas");
     m_entity.GetTeam().RefreshMemberList();
     m_entity.GetTeam().SetTeamAI(AITYPE.FIGHT);
 }
Example #7
0
 public void OnSeeDeath(GEntity entity)
 {
     if (Vector3.Distance(transform.position, entity.transform.position) > m_sight_range)
     {
         return;
     }
     m_entity.m_combatant.AttemptAllActions(TRIGGER.DEATH);
 }
Example #8
0
        internal void _setTopTile(int x, int y, GEntity tile)
        {
            Entities[y * LevelWidth + x] = null;
            Tiles[y * LevelWidth + x]    = tile;
            tile.Render(_background);
            _drawEntityOnScreen(tile);

            _miniMap.Set(tile);
        }
Example #9
0
 internal void _setTile(int x, int y, GEntity tile)
 {
     Tiles[y * LevelWidth + x] = tile;
     if (Entities[y * LevelWidth + x] == null)
     {
         tile.Render(_background);
         _miniMap.Set(tile);
     }
 }
Example #10
0
 public override void Render(GBitmap screen)
 {
     if (CurrentAnimState <= AnimationStates)
     {
         Directions Dir     = GEntity.GetOppositeDirection(Direction);
         int[]      Offsets = GetSparkOffsets(Dir);
         screen.Blit(Art.Rotate(Art.GRAPHICS[ImgXStart + CurrentAnimState, ImgYStart], (int)Dir * 90), iX + Offsets[0], iY + Offsets[1]);
     }
 }
        public static PlaySoundEntityInfo Create(GEntity bindingEntity, Vector3 worldPosition, object userData)
        {
            PlaySoundEntityInfo playSoundInfo = ReferencePool.Acquire <PlaySoundEntityInfo>();

            playSoundInfo.m_BindingEntity = bindingEntity;
            playSoundInfo.m_WorldPosition = worldPosition;
            playSoundInfo.m_UserData      = userData;
            return(playSoundInfo);
        }
Example #12
0
    void Start()
    {
        m_entity        = GetComponent <GEntity>();
        m_aim_lag_timer = new GameTimer(1f, true, RecordTargetPosition);

        /*
         *      m_combat_range = new MinMax(
         *              m_entity.m_combatant.GetShortestActionRange()*0.65f,
         *              m_entity.m_combatant.GetShortestActionRange()
         *      );
         */
    }
Example #13
0
 void Start()
 {
     m_entity      = GetComponent <GEntity>();
     m_root        = transform.Find("Appearance");
     m_animator    = transform.Find("Appearance").gameObject.GetComponent <Animator>();
     m_renderer    = transform.Find("Appearance").gameObject.GetComponent <SpriteRenderer>();
     m_shadow_root = transform.Find("Shadow");
     if (m_shadow_root != null)
     {
         m_shadow_animator = transform.Find("Shadow").gameObject.GetComponent <Animator>();
         m_shadow_renderer = transform.Find("Shadow").gameObject.GetComponent <SpriteRenderer>();
     }
 }
Example #14
0
        public void Set(GEntity e)
        {
            int sx = e.iX / GTile.WIDTH * _zoom;
            int sy = e.iY / GTile.HEIGHT * _zoom;

            for (int i = 0; i < _zoom; i++)
            {
                for (int j = 0; j < _zoom; j++)
                {
                    Image.SetPixel(sx + i, sy + j, LevelGen.GetEntityColor(e));
                }
            }
        }
Example #15
0
        public static Color GetEntityColor(GEntity g)
        {
            if (typeof(Spawner) == g.GetType())
            {
                if (g.Team == Teams.Blu)
                {
                    return(Color.DarkBlue);
                }
                else
                {
                    return(Color.FromArgb(190, 0, 0));
                }
            }
            switch (g.Type)
            {
            case TileType.WALL:
                return(Color.FromArgb(127, 64, 0));

            case TileType.METAL:
                return(Color.Silver);

            case TileType.GRAVEL:
                return(Color.Gray);

            case TileType.SAND:
                return(Color.Yellow);

            case TileType.GRASS:
                return(Color.LightGray);

            case TileType.WATER:
                return(Color.Blue);
            }

            if (g.Team != Teams.NoTeam)
            {
                if (typeof(Flag) == g.GetType())
                {
                    if (g.Team == Teams.Blu)
                    {
                        return(Color.FromArgb(0, 255, 255));
                    }
                    else
                    {
                        return(Color.Red);
                    }
                }
            }

            return(Color.Black);
        }
Example #16
0
    void OnTriggerExit(Collider c)
    {
        if (!m_active || !m_damage_on_exit)
        {
            return;
        }

        GEntity target = c.GetComponent <GEntity>();

        if (target != null && (target.m_team_id != m_owner.m_team_id || friendly_fire))
        {
            target.Damage(m_damage);
        }
    }
        public static List <Bullet> GetIntersectingBullets(GEntity Entity)
        {
            List <Bullet> IntersectingBullets = new List <Bullet>();

            foreach (Bullet B in Bullets)
            {
                if (Entity.Owner != B.Owner && B.IntersectsWith(Entity))
                {
                    IntersectingBullets.Add(B);
                }
            }

            return(IntersectingBullets);
        }
        public static List <GEntity> GetNonDraggableIntersectingEntities(GEntity Entity)
        {
            List <GEntity> IntersectingEntities = GetIntersectingEntities(Entity, IntersectionType.BY_DIFF_OWNER);

            for (int i = 0; i < IntersectingEntities.Count; ++i)
            {
                if (IntersectingEntities[i].Draggable)
                {
                    IntersectingEntities.RemoveAt(i);
                }
            }

            return(IntersectingEntities);
        }
        public static List <GEntity> GetIntersectingTiles(GEntity Entity)
        {
            List <GEntity> IntersectingTiles = new List <GEntity>();

            foreach (GEntity T in Tiles)
            {
                if (T.IntersectsWith(Entity))
                {
                    IntersectingTiles.Add(T);
                }
            }

            return(IntersectingTiles);
        }
        public static List <Bonus> GetIntersectingBonuses(GEntity Entity)
        {
            List <Bonus> IntersectingBonuses = new List <Bonus>();

            foreach (KeyValuePair <int, Bonus> B in Bonuses)
            {
                if (B.Value.IntersectsWith(Entity))
                {
                    IntersectingBonuses.Add(B.Value);
                }
            }

            return(IntersectingBonuses);
        }
        public static GEntity GetTile(int xt, int yt)
        {
            GEntity tT    = new GEntity(xt * GTile.WIDTH, yt * GTile.HEIGHT, 30, 30);
            GEntity Found = new GEntity(0, 0, 0, 0);

            foreach (GEntity T in Tiles)
            {
                if (T.IntersectsWith(tT))
                {
                    Found = T;
                }
            }

            return(Found);
        }
Example #22
0
        /// <summary>
        /// 设置声音绑定的实体。
        /// </summary>
        /// <param name="bindingEntity">声音绑定的实体。</param>
        public override void SetBindingEntity(GEntity bindingEntity)
        {
            m_BindingEntityLogic = bindingEntity.Logic;
            if (m_BindingEntityLogic != null)
            {
                UpdateAgentPosition();
                return;
            }

            if (m_ResetSoundAgentEventHandler != null)
            {
                ResetSoundAgentEventArgs resetSoundAgentEventArgs = ResetSoundAgentEventArgs.Create();
                m_ResetSoundAgentEventHandler(this, resetSoundAgentEventArgs);
                ReferencePool.Release(resetSoundAgentEventArgs);
            }
        }
Example #23
0
 private static void _write(GEntity entity, ref int pos, byte[] arr)
 {
     Write(entity.X, ref pos, ref arr);
     Write(entity.Y, ref pos, ref arr);
     Write(entity.Type, ref pos, ref arr);
     if (entity.Type == EntityType.MINE)
     {
         Write(Convert.ToInt32(((Mine)entity).Countdown), ref pos, ref arr);
     }
     else
     {
         Write(entity.Health, ref pos, ref arr);
     }
     Write(entity.Owner, ref pos, ref arr);
     Write(entity.Direction, ref pos, ref arr);
 }
Example #24
0
        public G1(Game game, Camera camera)
            : base(game, camera)
        {
            position  = new Vector3(-8, 37.5f, 30);
            yrotation = 0;
            type      = TrialType.GRAB;

            GEntity loc = new GEntity(game, new Vector3(-62.5f, 55.75f, 185.5f), camera, "models/tavern/lock", "textures/brass_dark");

            loc.scale = 10;
            this.draggableList.Add(loc);
            loc       = new GEntity(game, new Vector3(46f, 55.75f, 185.5f), camera, "models/tavern/lock", "textures/brass_dark");
            loc.scale = 10;
            this.draggableList.Add(loc);

            Door door = new Door(game, camera, new Vector3(-47.5f, 5.75f, 185.5f), 0);

            door.scale = 10;
            this.sceneryList.Add(door);
            door       = new Door(game, camera, new Vector3(31f, 5.75f, 185.5f), 0);
            door.scale = 10;
            this.sceneryList.Add(door);
            sceneryList.Insert(0, new GEntity(game, new Vector3(-20, 5, 75), camera, "models/tavern/table", "textures/tavern/table_color"));
            sceneryList[0].scale = 3;


            switch (Game1.InputMode)
            {
            case InputMode.KINECT:
                preTrialInstructions = "Once an object has been selected, it can be grabbed by\n" + "      forming a fist with your hand, and dragged.\n" +
                                       "Practice peforming the drag gesture.";
                break;

            case InputMode.WAND:
                preTrialInstructions = "Once an object has been selected, it can be grabbed by\n" + "      holding the B button, and dragged.\n" +
                                       "Practice peforming the drag gesture.";
                break;

            case InputMode.MOUSE:
                preTrialInstructions = "Once an object has been selected, it can be grabbed by\n" + "      clicking the right mouse button, and dragged.\n" +
                                       "Practice peforming the drag gesture.";
                break;
            }
            inTrialInstructions = "Select each key that appears, and drag it to the coloured lock.";
            Game1.wandCursor.DisplayingWithoutGesture = true;
            this.camera = camera;
        }
        public static List <GEntity> GetIntersectingEntities(GEntity Entity, int IntType)
        {
            List <GEntity> IntersectingEntities = new List <GEntity>();

            foreach (GEntity E in Entities)
            {
                if ((IntType == IntersectionType.NOT_DETECTED ||
                     (IntType == IntersectionType.BY_DIFF_OWNER && Entity.Owner != E.Id)) &&
                    E.IntersectsWith(Entity) &&
                    !E.CanPass)
                {
                    IntersectingEntities.Add(E);
                }
            }

            return(IntersectingEntities);
        }
Example #26
0
    GEntity GetClostestAllyInSight()
    {
        GEntity target          = null;
        float   target_distance = m_sight_range;

        GEntity[] entities = GameObject.FindObjectsOfType <GEntity>();
        foreach (GEntity ge in entities)
        {
            if (m_entity.m_team_id == ge.m_team_id &&
                Vector3.Distance(transform.position, ge.transform.position) <= target_distance)
            {
                target_distance = Vector3.Distance(transform.position, ge.transform.position);
                target          = ge;
            }
        }
        return(target);
    }
Example #27
0
    void OnTriggerStay(Collider c)
    {
        if (!m_active ||
            !m_damage_on_stay ||
            !m_stay_damage_begin_timer.IsComplete() ||
            !m_stay_damage_repeat_timer.IsComplete()
            )
        {
            return;
        }

        GEntity target = c.GetComponent <GEntity>();

        if (target != null && (target.m_team_id != m_owner.m_team_id || friendly_fire))
        {
            target.Damage(m_damage);
        }
    }
Example #28
0
    void AIStateFight()
    {
        GEntity nearby_enemy = GetClosestEnemyInSight();

        if (nearby_enemy != null)
        {
            AIPursue(nearby_enemy);
        }
        else
        {
            GTeam team = m_entity.m_controller.GetTeam(m_entity.m_team_id);
            if (team != null && team.GetLeader() != null)
            {
                AIFollow(team.GetLeader());
            }
        }
        AIUseActions();
    }
Example #29
0
        private static MapEntity _tileToMapEntity(GEntity tile)
        {
            switch (tile.Type)
            {
            case TileType.WATER:
                return(MapEntity.Water);

            case TileType.SAND:
                return(MapEntity.Sand);

            case TileType.GRASS:
                return(MapEntity.Gravel);

            case TileType.GRAVEL:
                return(MapEntity.Gravel);
            }
            throw new ArgumentException("Unknown type of tile");
        }
Example #30
0
        public P2(Game game, Camera camera)
            : base(game, camera)
        {
            position  = new Vector3(330, 150, -525);
            yrotation = MathHelper.PiOver2;

            Pedestal pedestal = new Pedestal(game, camera, new Vector3(440, 100, -525));

            pedestal.scale      = 10;
            pedestal.Selectable = true;
            pedestal.yrotation  = MathHelper.Pi;
            selectableList.Insert(0, pedestal);

            GEntity table = new GEntity(game, new Vector3(400, 101, -525), camera, "models/tavern/round_table", "textures/tavern/round_table_color");

            table.scale = 5;
            sceneryList.Add(table);
            table       = new GEntity(game, new Vector3(420, 101, -460), camera, "models/tavern/round_table", "textures/tavern/round_table_color");
            table.scale = 5;
            sceneryList.Add(table);
            table       = new GEntity(game, new Vector3(420, 101, -590), camera, "models/tavern/round_table", "textures/tavern/round_table_color");
            table.scale = 5;
            sceneryList.Add(table);

            GEntity statue = new GEntity(game, new Vector3(400, 121, -525), camera, "models/statues/snake", null);

            statue.scale         = 8;
            statue.yrotation     = MathHelper.Pi;
            statue.selectedColor = Color.Yellow;
            selectableList.Insert(0, statue);
            statue               = new GEntity(game, new Vector3(420, 121, -460), camera, "models/statues/man", null);
            statue.scale         = 8;
            statue.yrotation     = MathHelper.Pi;
            statue.selectedColor = Color.Yellow;
            selectableList.Insert(0, statue);
            statue               = new GEntity(game, new Vector3(420, 121, -590), camera, "models/statues/tree", null);
            statue.scale         = 8;
            statue.yrotation     = MathHelper.Pi;
            statue.selectedColor = Color.Yellow;
            selectableList.Insert(0, statue);

            renderRequested = true;
        }