示例#1
0
        public override void OnStartClient()
        {
            base.OnStartAuthority();

            //Initialization code for local player (local client on the host, and remote clients).
            this.oldTargetPosition      = Vector3.one * -9999f;
            this.oldEnemyTargetPosition = Vector3.one * -9999f;
            this.targetEnemy            = null;
            this.targetAIEnemy          = null;
            this.isSelected             = false;
            this.isDirected             = false;
            this.currentHealth          = this.maxHealth;
            this.recoverCounter         = 1f;
            //this.recoverCooldown = this.attackCooldown + 3.5f;
            this.attackCooldownCounter = this.attackCooldown;
            this.teamFaction           = EnumTeam.Player;
            if (this.attackPower <= 1f)
            {
                this.attackPower = 1f;
            }
            this.level         = 1;
            this.previousLevel = 1;

            UpdateUnitAttributes();

            Renderer renderer = this.GetComponent <Renderer>();

            if (renderer != null)
            {
                this.initialColor = renderer.material.color;
            }
        }
示例#2
0
        private Team(int teamId, string name, Color color)
        {
            this.teamId       = teamId;
            this.internalName = name;
            this.teamName     = char.ToUpper(name[0]) + name.Substring(1);
            this.color        = color;
            this.enumTeam     = (EnumTeam)this.teamId;

            this.predicateThisTeam  = (MapObject obj) => { return(obj is SidedObjectEntity && ((SidedObjectEntity)obj).getTeam() == this); };
            this.predicateOtherTeam = (MapObject obj) => { return(obj is SidedObjectEntity && ((SidedObjectEntity)obj).getTeam() != this); };
        }
示例#3
0
    private Team(int teamId, string name, EnumTeam enumTeam, Color color)
    {
        this.teamId   = teamId;
        this.teamName = char.ToUpper(name[0]) + name.Substring(1);
        this.color    = color;
        this.enumTeam = enumTeam;

        this.predicateThisTeam     = (MapObject obj) => { return(obj is SidedEntity && ((SidedEntity)obj).getTeam() == this); };
        this.predicateThisTeamUnit = (MapObject obj) => { return(this.predicateThisTeam(obj) && obj is UnitBase); };
        this.predicateOtherTeam    = (MapObject obj) => { return(obj is SidedEntity && ((SidedEntity)obj).getTeam() != this); };
    }
示例#4
0
        public static Team getTeamFromEnum(EnumTeam enumTeam)
        {
            switch (enumTeam)
            {
            case EnumTeam.GREEN: return(Team.GREEN);

            case EnumTeam.PURPLE: return(Team.PURPLE);

            case EnumTeam.ORANGE: return(Team.ORANGE);

            case EnumTeam.BLUE: return(Team.BLUE);

            case EnumTeam.NONE:
            default: return(Team.NONE);
            }
        }
示例#5
0
    public static Team getTeamFromEnum(EnumTeam enumTeam)
    {
        switch (enumTeam)
        {
        case EnumTeam.GREEN: return(Team.SURVIVORS_3);

        case EnumTeam.PURPLE: return(Team.SURVIVORS_4);

        case EnumTeam.ORANGE: return(Team.SURVIVORS_1);

        case EnumTeam.BLUE: return(Team.SURVIVORS_2);

        case EnumTeam.BLACK: return(Team.ZOMBIES);

        case EnumTeam.NONE:
        default: return(Team.NONE);
        }
    }
示例#6
0
        public void SetTeam(EnumTeam teamFaction)
        {
            this.teamFaction = teamFaction;
            switch (teamFaction)
            {
            case EnumTeam.Player:
                this.SetTeamColor(0);
                break;

            case EnumTeam.Computer:
                this.SetTeamColor(-1);
                break;

            case EnumTeam.Neutral:
                this.SetTeamColor((int)UnityEngine.Random.Range(0, 3));
                break;
            }
        }
示例#7
0
    public GameObject[] FindAll(EnumTeam team)
    {
        List <GameObject> enemies = new List <GameObject>();

        if (player.team == team)
        {
            enemies.Add(player.gameObject);
        }

        foreach (ObjectPool creepPool in laneCreeps)
        {
            foreach (GameObject creep in creepPool.ToArray())
            {
                if (creep.GetComponent <IEntity>().team == team)
                {
                    enemies.Add(creep);
                }
            }
        }

        return(enemies.ToArray());
    }
示例#8
0
    public IEntity FindTarget(EnumTeam enemyTeam, Vector3 position, Vector3 lookingAt)
    {
        IEntity target = null;

        foreach (GameObject enemy in FindAll(enemyTeam))
        {
            Vector3 targetDir = enemy.transform.position - position;
            float   angle     = (Vector3.Angle(targetDir, lookingAt));

            if (angle >= -90 && angle <= 90)
            {
                if (target == null)
                {
                    target = enemy.GetComponent <IEntity>();
                }
                else if (Vector3.Distance(position, target.transform.position) > Vector3.Distance(position, enemy.transform.position))
                {
                    target = enemy.GetComponent <IEntity>();
                }
            }
        }

        return(target);
    }
示例#9
0
        public void Copy(AIUnit original)
        {
            this.currentState         = original.currentState;
            this.splitFactor          = original.splitFactor;
            this.mergeFactor          = original.mergeFactor;
            this.attackCooldownFactor = original.attackCooldownFactor;
            this.attackFactor         = original.attackFactor;
            this.unitManager          = original.unitManager;
            this.currentHealth        = original.currentHealth;
            this.maxHealth            = original.maxHealth;
            this.splitCounter         = original.splitCounter;
            this.minimapCameraRect    = original.minimapCameraRect;
            this.teamFaction          = original.teamFaction;

            this.SetTeamColor(original.teamColorValue);

            AILineOfSight myLOS       = this.GetComponentInChildren <AILineOfSight>();
            AILineOfSight originalLOS = original.GetComponentInChildren <AILineOfSight>();
            AIAttackRange myAR        = this.GetComponentInChildren <AIAttackRange>();
            AIAttackRange originalAR  = original.GetComponentInChildren <AIAttackRange>();

            myLOS.teamFaction = originalLOS.teamFaction;
            myAR.teamFaction  = originalAR.teamFaction;
        }
示例#10
0
        public void Copy(AIUnit original)
        {
            this.currentState = original.currentState;
            this.splitFactor = original.splitFactor;
            this.mergeFactor = original.mergeFactor;
            this.attackCooldownFactor = original.attackCooldownFactor;
            this.attackFactor = original.attackFactor;
            this.unitManager = original.unitManager;
            this.currentHealth = original.currentHealth;
            this.maxHealth = original.maxHealth;
            this.splitCounter = original.splitCounter;
            this.minimapCameraRect = original.minimapCameraRect;
            this.teamFaction = original.teamFaction;

            this.SetTeamColor(original.teamColorValue);

            AILineOfSight myLOS = this.GetComponentInChildren<AILineOfSight>();
            AILineOfSight originalLOS = original.GetComponentInChildren<AILineOfSight>();
            AIAttackRange myAR = this.GetComponentInChildren<AIAttackRange>();
            AIAttackRange originalAR = original.GetComponentInChildren<AIAttackRange>();

            myLOS.teamFaction = originalLOS.teamFaction;
            myAR.teamFaction = originalAR.teamFaction;
        }
示例#11
0
 /// <summary>
 /// Sets the team that this Entity is on.
 /// </summary>
 public void setTeam(Team newTeam)
 {
     this.team = newTeam;
     // Used to help debug in the inspector, so we can see the objects team.
     this.objectTeam = this.team.getEnum();
 }
示例#12
0
        public override void OnStartClient()
        {
            base.OnStartAuthority();

            //Initialization code for local player (local client on the host, and remote clients).
            this.oldTargetPosition = Vector3.one * -9999f;
            this.oldEnemyTargetPosition = Vector3.one * -9999f;
            this.targetEnemy = null;
            this.targetAIEnemy = null;
            this.isSelected = false;
            this.isDirected = false;
            this.currentHealth = this.maxHealth;
            this.recoverCounter = 1f;
            //this.recoverCooldown = this.attackCooldown + 3.5f;
            this.attackCooldownCounter = this.attackCooldown;
            this.teamFaction = EnumTeam.Player;
            if (this.attackPower <= 1f) {
                this.attackPower = 1f;
            }
            this.level = 1;
            this.previousLevel = 1;

            UpdateUnitAttributes();

            Renderer renderer = this.GetComponent<Renderer>();
            if (renderer != null) {
                this.initialColor = renderer.material.color;
            }
        }
示例#13
0
 public void SetTeam(EnumTeam teamFaction)
 {
     this.teamFaction = teamFaction;
     switch (teamFaction) {
         case EnumTeam.Player:
             this.SetTeamColor(0);
             break;
         case EnumTeam.Computer:
             this.SetTeamColor(-1);
             break;
         case EnumTeam.Neutral:
             this.SetTeamColor((int) UnityEngine.Random.Range(0, 3));
             break;
     }
 }
示例#14
0
 public bool IsEnemy(EnumTeam other)
 {
     return(team != other && other != EnumTeam.TRIGGER && team != EnumTeam.TRIGGER);
 }