Exemple #1
0
    private void Awake()
    {
        _body        = new AgentBody();
        _physics     = new AgentPhysics(transform, GetComponent <Rigidbody2D>(), this);
        _state       = new StateMachine();
        _animation   = new AgentAnimation(this, GetComponent <SkeletonAnimation>());
        _groundcheck = GetComponent <GroundCheck>();
        _stats       = new AgentStats(this);
        _agentSkills = GetComponent <AgentSkills>();
        _health      = GetComponent <AgentHealth>();
        _state.ChangeState(new GroundedState(this));

        if (tag == "Player")
        {
            DeathManager.Player = this;
        }
        else
        {
            if (DeathManager.Enemies == null)
            {
                DeathManager.Enemies = new List <Agent>();
            }
            DeathManager.Enemies.Add(this);
        }
    }
Exemple #2
0
 public State(Agent agent)
 {
     _agent         = agent;
     _brain         = agent.Brain;
     _stateMachine  = agent.StateMachine;
     _agentBody     = agent.Body;
     _agentSettings = agent.Settings;
 }
Exemple #3
0
 public AgentAnimation(Agent agent, SkeletonAnimation animation)
 {
     _agent              = agent;
     _animation          = animation;
     _body               = agent.Body;
     _body.OnJump       += Jump;
     _body.OnFall       += Fall;
     _body.OnRoll       += Roll;
     _body.OnCrouch     += Crouch;
     _body.OnTakeDamage += TakeDamage;
     _body.OnDeath      += Death;
 }
Exemple #4
0
        public AgentBodySimulation(List <Plane> Pl, List <Polyline> body, double searchRadius)
        {
            Agents             = new AgentBody[Pl.Count];
            agentsRTree        = new RTree();
            this.searchRadius  = searchRadius;
            deviationThreshold = 0.01; // to be implemented in the future (stop when global deviation under this threshold)

            // . . . . . . . . . . . . . . . . . . . . . . . . build agents array & RTree
            // since agents are fixed it can be built in advance
            for (int i = 0; i < Pl.Count; i++)
            {
                Agents[i] = new AgentBody(Pl[i], body);
                agentsRTree.Insert(Agents[i].agentPlane.Origin, i);
            }

            // . . . . . . . . . . . . . . . . . . . . . . . . . . . build neighbours map
            FindNeighbours(this.searchRadius);
            foreach (AgentBody ab in Agents)
            {
                ab.FindTipNeighbour();
            }
        }