Beispiel #1
0
    private void makeTeam(Team team, bool makePlayer)
    {
        CombatTeam combatTeam = new CombatTeam();

        TeamTarget allies  = TeamTarget.TargetJust(combatTeam);
        TeamTarget enemies = TeamTarget.TargetAllExcept(combatTeam);

        for (int i = 0; i < team.ShipCount; i++)
        {
            makeShip(team.Prefab, combatTeam, allies, enemies, new Vector3(team.Pos.x + Random.Range(-Dist, Dist), 0, team.Pos.z + Random.Range(-Dist, Dist)));
        }

        if (makePlayer)
        {
            // Make cursor
            MonoBehaviour.Instantiate(cursor, new Vector3(0, 0, 0), Quaternion.identity);

            // Reset player for start of combat.
            GameObject player = GameObject.FindGameObjectWithTag("ShipBlueprint");
            player.transform.position = new Vector3(team.Pos.x + +Random.Range(-Dist, Dist), 0, team.Pos.z + Random.Range(-Dist, Dist));
            player.transform.rotation = new Quaternion(0, 0, 0, 0);
            player.GetComponent <TeamMarker>().Team            = combatTeam;
            player.GetComponent <TargetMarker>().AlliedTargets = allies;
            player.GetComponent <TargetMarker>().EnemyTargets  = enemies;

            PlayerActivation activater = player.GetComponent <PlayerActivation>();
            activater.Recreate();
            activater.SetBehavioursEnabled(true);
            activater.Show();
        }
    }
Beispiel #2
0
        public BaseNpc(string Name, Transform Trans, CombatTeam Team, float[] InitAttr)
            : base(Name, Trans)
        {
            this.Team     = Team;
            this.IsStatic = false;

            this.ModuleList_  = new List <BaseNpcModule>();
            this.HandlerList_ = new List <BaseNpcHandler>();

            FrontLayer = MiscHelper.CreateCanvasLayer(Trans, "Front", Configure.NpcFrontOrder);
            BackLayer  = MiscHelper.CreateCanvasLayer(Trans, "Back", Configure.NpcBackOrder);

            EventManager.Register <NpcAttrChangedEvent>(OnNpcAttrChangedEvent);

            this.Data   = AddModule(new NpcDataModule(this, InitAttr, 0));
            this.Actor  = AddModule(new NpcActorModule(this));
            this.Action = AddModule(new NpcActionModule(this));
            this.Skill  = AddModule(new NpcSkillModule(this));

            this.Bar_ = new NpcBar(this, Trans.Find("Bar").localPosition);
            this.Bar_.SetMaxHp(CalcFinalAttr(NpcAttrIndex.MaxHp));
            this.Bar_.SetMaxMp(CalcFinalAttr(NpcAttrIndex.MaxMp));
            this.HitSfxInterval_ = 0;

            Actor.RegisterMsg("Attack", 0.75f, CombatMsgCode.Atk);
            Actor.ChangeToIdleState();
        }
Beispiel #3
0
        public static AINpc AddNpc(string Name, Vector2 Position, CombatTeam Team, float Scale, float[] InitAttr)
        {
            // temp code, r1 or r2 role
            var AtkRange = InitAttr[(int)NpcAttrIndex.AtkRange];

            var Obj = AssetManager.CreatePrefabSync(new AssetUri(AtkRange > 100 ? "prefabs/npc/r1/r1.prefab" : "prefabs/npc/r2/r2.prefab"));

            MapManager.AddToNpcLayer(Obj.transform);
            Obj.transform.localPosition = Position;

            var Entity = new AINpc(Name, Obj.transform, Team, InitAttr);

            NpcList_[(int)Team].Add(Entity);
            Entity.Position = Position;
            Entity.Scale    = new Vector2(Scale, Scale);
            Entity.GetBar().SetScale(0.5f);

            if (AtkRange > 100)
            {
                Entity.Skill.AddNpcSkill(1002).Radius = CombatHelper.GetNpcAtkRange(Entity);
            }
            else
            {
                Entity.Skill.AddNpcSkill(1001).Radius = CombatHelper.GetNpcAtkRange(Entity);
            }

            EventManager.Send(new NpcAddEvent(Entity));
            return(Entity);
        }
Beispiel #4
0
    /// Finds the nearest target to the given position.
    /// Returns null if no such target exists.
    public GameObject FindNearestTarget(Vector3 to)
    {
        float      minimumDistance = float.PositiveInfinity;
        GameObject result          = null;

        // Loop over every ship, checking if this missile is targeting their team.
        // TODO: Also loop over space-flares! Possibly by marking flares as your team.
        // TODO: Seperate missiles and ships, so flares can work properly.
        foreach (GameObject ship in TeamMarker.GetAllMarkedGameObjects())
        {
            CombatTeam team = ship.GetComponent <TeamMarker>().Team;
            if (IsTargeting(team))
            {
                float distance = Vector3.Distance(ship.transform.position, to);

                // This ship is closer than the previously closest ship.
                if (distance < minimumDistance)
                {
                    result          = ship;
                    minimumDistance = distance;
                }
            }
        }

        return(result);
    }
Beispiel #5
0
 public BaseBulletDescriptor(string Name, Vector2 Position, CombatTeam Team, float Damage)
 {
     this.Name     = Name;
     this.Position = Position;
     this.Damage   = Damage;
     this.Team     = Team;
 }
Beispiel #6
0
        public static List <BaseNpc> GetNpcList(CombatTeam Team)
        {
            var Result = new List <BaseNpc>();

            if (Team == CombatTeam.All)
            {
                foreach (var Npc in NpcList_[0])
                {
                    if (Npc.IsValid())
                    {
                        Result.Add(Npc);
                    }
                }

                foreach (var Npc in NpcList_[1])
                {
                    if (Npc.IsValid())
                    {
                        Result.Add(Npc);
                    }
                }
            }
            else
            {
                foreach (var Npc in NpcList_[(int)Team])
                {
                    if (Npc.IsValid())
                    {
                        Result.Add(Npc);
                    }
                }
            }

            return(Result);
        }
Beispiel #7
0
    private void makeTeam(Team team, bool makePlayer)
    {
        CombatTeam combatTeam = new CombatTeam();

        TeamTarget allies = TeamTarget.TargetJust(combatTeam);
        TeamTarget enemies = TeamTarget.TargetAllExcept(combatTeam);

        for (int i = 0; i < team.ShipCount; i++) {
          makeShip(team.Prefab, combatTeam, allies, enemies, new Vector3(team.Pos.x + Random.Range(-Dist, Dist), 0, team.Pos.z + Random.Range(-Dist, Dist)));
        }

        if (makePlayer) {
          // Make cursor
          MonoBehaviour.Instantiate(cursor, new Vector3(0, 0, 0), Quaternion.identity);

          // Reset player for start of combat.
          GameObject player = GameObject.FindGameObjectWithTag("ShipBlueprint");
          player.transform.position = new Vector3(team.Pos.x + + Random.Range(-Dist, Dist), 0, team.Pos.z + Random.Range(-Dist, Dist));
          player.transform.rotation = new Quaternion(0, 0, 0, 0);
          player.GetComponent<TeamMarker>().Team = combatTeam;
          player.GetComponent<TargetMarker>().AlliedTargets = allies;
          player.GetComponent<TargetMarker>().EnemyTargets = enemies;

          PlayerActivation activater = player.GetComponent<PlayerActivation>();
          activater.Recreate();
          activater.SetBehavioursEnabled(true);
          activater.Show();

        }
    }
Beispiel #8
0
        // Token: 0x0600378A RID: 14218 RVA: 0x000F9D90 File Offset: 0x000F7F90
        private void SetupTeam(int teamNumber, BattleActor battleActor, ConfigDataSkillInfo heroSkillInfo)
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_SetupTeamInt32BattleActorConfigDataSkillInfo_hotfix != null)
            {
                this.m_SetupTeamInt32BattleActorConfigDataSkillInfo_hotfix.call(new object[]
                {
                    this,
                    teamNumber,
                    battleActor,
                    heroSkillInfo
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            if (battleActor == null)
            {
                return;
            }
            CombatTeam combatTeam = this.m_teams[teamNumber];

            combatTeam.Initialize(this, teamNumber, battleActor, heroSkillInfo);
            int num  = this.ConfigDataLoader.Const_CombatHeroDistance / -2;
            int num2 = -20;
            int num3 = 1;

            if (this.GetCombatGridDistance() > 1)
            {
                num -= this.ConfigDataLoader.Const_CombatSplitScreenDistance / 2;
            }
            if (teamNumber != 0)
            {
                num  = -num;
                num3 = -1;
            }
            if (battleActor.HeroInfo != null)
            {
                CombatActor combatActor = combatTeam.CreateActor(true);
                combatActor.SetPosition(num, num2);
                combatActor.SetDirection(num3);
                combatActor.SetFormationLine(9);
            }
            if (battleActor.SoldierInfo != null)
            {
                int soldierCount = battleActor.GetSoldierCount();
                for (int i = 0; i < soldierCount; i++)
                {
                    CombatActor combatActor2      = combatTeam.CreateActor(false);
                    Position2i  formationPosition = combatTeam.GetFormationPosition(i);
                    combatActor2.SetPosition(num + formationPosition.x * num3, num2 + formationPosition.y);
                    combatActor2.SetDirection(num3);
                    combatActor2.SetFormationLine(combatTeam.GetFormationLine(i));
                    if (i == soldierCount - 1)
                    {
                        combatActor2.SetHealthPoint(battleActor.SoldierTotalHealthPoint - combatActor2.HealthPointMax * (soldierCount - 1));
                    }
                }
            }
        }
Beispiel #9
0
    private void makeShip(GameObject prefab, CombatTeam team, TeamTarget allies, TeamTarget enemies, Vector3 pos)
    {
        Quaternion rot = new Quaternion(0, 0, 0, 0);
        GameObject ship = MonoBehaviour.Instantiate(prefab, pos, rot) as GameObject;

        ship.GetComponent<TeamMarker>().Team = team;
        ship.GetComponent<TargetMarker>().AlliedTargets = allies;
        ship.GetComponent<TargetMarker>().EnemyTargets = enemies;
    }
Beispiel #10
0
 public AINpc(string Name, Transform Trans, CombatTeam Team, float[] InitAttr)
     : base(Name, Trans, Team, InitAttr)
 {
     AIData_          = new BehaviorInputData();
     AIData_.Enabled  = true;
     AIData_.Attacker = this;
     AIData_.Node     = AIFactory.CreateNormalAI();
     AIData_.SkillID  = 0;
 }
Beispiel #11
0
    private void makeShip(GameObject prefab, CombatTeam team, TeamTarget allies, TeamTarget enemies, Vector3 pos)
    {
        Quaternion rot  = new Quaternion(0, 0, 0, 0);
        GameObject ship = MonoBehaviour.Instantiate(prefab, pos, rot) as GameObject;

        ship.GetComponent <TeamMarker>().Team            = team;
        ship.GetComponent <TargetMarker>().AlliedTargets = allies;
        ship.GetComponent <TargetMarker>().EnemyTargets  = enemies;
    }
Beispiel #12
0
 public void Setup(BasicChar who, CombatTeam combatTeam, CombatMain main)
 {
     whom       = who;
     title.text = whom.Identity.FirstName;
     healthSlider.Setup(whom);
     willSlider.Setup(whom);
     Dead       = false;
     team       = combatTeam;
     combatMain = main;
     btn.onClick.AddListener(Select);
     whom.HP.DeadEvent += HasDied;
     whom.WP.DeadEvent += HasDied;
 }
Beispiel #13
0
        public static CombatTeam Opposite(this CombatTeam Team)
        {
            switch (Team)
            {
            case CombatTeam.A:
                return(CombatTeam.B);

            case CombatTeam.B:
                return(CombatTeam.A);

            default:
                return(Team);
            }
        }
Beispiel #14
0
        // Token: 0x060038A4 RID: 14500 RVA: 0x00101A38 File Offset: 0x000FFC38
        private CombatActor SearchHitTarget(Fix64 x0, Fix64 x1, ushort hitId)
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_SearchHitTargetFix64Fix64UInt16_hotfix != null)
            {
                return((CombatActor)this.m_SearchHitTargetFix64Fix64UInt16_hotfix.call(new object[]
                {
                    this,
                    x0,
                    x1,
                    hitId
                }));
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            CombatTeam  team   = this.Combat.GetTeam(this.m_targetTeamNumber);
            int         num    = int.MaxValue;
            CombatActor result = null;
            int         num2   = (int)((long)(x0 + x1)) / 2;
            int         num3   = Math.Abs((int)((long)(x0 - x1)) / 2) + this.m_configDataFlyObjectInfo.CollisionRadius;

            if (!this.m_team.IsAttackHeroOnly())
            {
                foreach (CombatActor combatActor in team.GetActors())
                {
                    if (combatActor.CanBeTarget())
                    {
                        if (Math.Abs((int)((long)combatActor.Position.x) - num2) <= num3 + combatActor.Radius)
                        {
                            if (!combatActor.HasBeHitId(hitId))
                            {
                                int num4 = CombatFlyObject.ComputeTargetScore(x1, combatActor);
                                if (num4 < num)
                                {
                                    num    = num4;
                                    result = combatActor;
                                }
                            }
                        }
                    }
                }
                return(result);
            }
            CombatActor hero = team.GetHero();

            if (hero != null && hero.CanBeTarget() && Math.Abs((int)((long)hero.Position.x) - num2) <= num3 + hero.Radius)
            {
                return(hero);
            }
            return(null);
        }
Beispiel #15
0
 // Token: 0x0600389F RID: 14495 RVA: 0x0010138C File Offset: 0x000FF58C
 public void Initialize(CombatTeam team)
 {
     if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_InitializeCombatTeam_hotfix != null)
     {
         this.m_InitializeCombatTeam_hotfix.call(new object[]
         {
             this,
             team
         });
         return;
     }
     BJLuaObjHelper.IsSkipLuaHotfix = false;
     this.m_team = team;
     this.m_id   = this.Combat.GetNextEntityId();
 }
Beispiel #16
0
        public static BaseNpc FindNpc(CombatTeam Team, uint ID)
        {
            if (ID == 0)
            {
                return(null);
            }

            foreach (var Entity in NpcList_[(int)Team])
            {
                if (Entity.ID == ID)
                {
                    return(Entity);
                }
            }

            return(null);
        }
Beispiel #17
0
    protected override void instantEffects()
    {
        Vector3    pos = this.position;
        Quaternion rot = new Quaternion(0, 0, 0, 0);

        GameObject[] flares  = new GameObject[NumFlares];
        GameObject   ship    = this.GetComponent <Ability>().Ship;
        TeamTarget   allies  = ship.GetComponent <TargetMarker>().AlliedTargets;
        TeamTarget   enemies = ship.GetComponent <TargetMarker>().EnemyTargets;
        CombatTeam   team    = ship.GetComponent <TeamMarker>().Team;

        for (int i = 0; i < NumFlares; i++)
        {
            flares[i] = Instantiate(FlarePrefab, pos, rot) as GameObject;
            flares[i].transform.Rotate(0, Random.Range(0.0f, 360.0f), 0);
            flares[i].transform.Translate(Random.Range(1.0f, 20.0f), -5, 0);
            flares[i].GetComponent <TeamMarker>().Team            = team;
            flares[i].GetComponent <TargetMarker>().AlliedTargets = allies;
            flares[i].GetComponent <TargetMarker>().EnemyTargets  = enemies;
            Destroy(flares[i], 10);
        }
    }
Beispiel #18
0
 /// Targets only the given team.
 /// More effecient than the Target method.
 public static TeamTarget TargetJust(CombatTeam target)
 {
     return new TeamTarget(delegate(CombatTeam team) {
       return target == team;
     });
 }
Beispiel #19
0
 public void RegisterTeam(CombatTeam team)
 {
     m_pawnTeam = team;
 }
 public void ChangeActingTeam(CombatTeam team)
 {
     curCombatTeam = team;
 }
Beispiel #21
0
 /// Whether the weapon is targeting the given team.
 public bool IsTargeting(CombatTeam team)
 {
     return(condition(team));
 }
Beispiel #22
0
 /// Targets only the given team.
 /// More effecient than the Target method.
 public static TeamTarget TargetJust(CombatTeam target)
 {
     return(new TeamTarget(delegate(CombatTeam team) {
         return target == team;
     }));
 }
    public void KillTeam(CombatTeam team)
    {
        switch (team) {

            case CombatTeam.Player:

                playerTeam.KillTeam();

                /*
                foreach (TileAgent agent in playerTeam.teamMembers) {
                    agent.GetComponent<BaseStats>().currentHealth = 0.0f;
                }
                */

                break;

            case CombatTeam.Enemy:
                enemyTeam.KillTeam();
                /*
                foreach (TileAgent agent in enemyTeam.teamMembers) {
                    agent.GetComponent<BaseStats>().currentHealth = 0.0f;
                }
                */
                break;
        }

        ChangeCombatState(CombatPhase.ExitCombat);
    }
Beispiel #24
0
        //sub_5F87B
        internal static void RemoveComplimentSpellFirst(string text, CombatTeam combatTeam, Affects affect)
        {
            gbl.byte_1D2C7 = true;

            int maxTargets = ovr025.spellMaxTargetCount(gbl.spell_id);

            gbl.spellTargets.RemoveAll(target =>
                {
                    if (target.combat_team == combatTeam && maxTargets > 0)
                    {
                        maxTargets -= 1;

                        if (ovr024.cure_affect(affect, target) == true)
                        {
                            return true;
                        }
                    }
                    else
                    {
                        return true;
                    }
                    return false;
                });

            DoSpellCastingWork(text, 0, 0, false, 0, gbl.spell_id);
        }
Beispiel #25
0
        // sub_5DCA0
        static void CastTeamSpell(string text, CombatTeam team)
        {
            gbl.byte_1D2C7 = true;

            gbl.spellTargets.RemoveAll(target => target.combat_team != team ||
                (gbl.spell_id == (int)Spells.bless && gbl.game_state == GameState.Combat && ovr025.BuildNearTargets(1, target).Count > 0));

            DoSpellCastingWork(text, 0, 0, false, 0, gbl.spell_id);
        }
Beispiel #26
0
 /// Whether the weapon is targeting the given team.
 public bool IsTargeting(CombatTeam team)
 {
     return condition(team);
 }
Beispiel #27
0
 public TeamController(CombatTeam owner)
 {
     this.team = owner;
     Init();
 }
 public PlayerTeamController(CombatTeam owner) : base(owner)
 {
 }