Exemplo n.º 1
0
 public override void SetChoice(AdventurerAgent agent, int input)
 {
     if (Enum.IsDefined(typeof(EAdventurerScreen), input))
     {
         AgentInput.ChangeScreen(agent, (EAdventurerScreen)input);
     }
 }
Exemplo n.º 2
0
 /**
  * Static constructor.
  */
 static EventUtils()
 {
     m_mainScript            = GameObject.Find("ScriptHub").GetComponent <Main>();
     m_agentScript           = GameObject.Find("Agent").GetComponent <AgentInput>();
     m_sessionScript         = GameObject.Find("ScriptHub").GetComponent <SessionBehavior>();
     m_ballScript            = GameObject.Find("Ball").GetComponent <BallBehavior>();
     m_dataScript            = GameObject.Find("ScriptHub").GetComponent <DataManger>();
     m_ballObservationScript = GameObject.Find("Ball").GetComponent <BallObservation>();
 }
Exemplo n.º 3
0
    public void ExecuteForces(AgentInput input)
    {
        float desiredAngularVelocity = speedLimit * input.aimDirection;
        float currentAngularVelocity = agent.angularVelocity.y;

        float difference = forceMultiplier * (desiredAngularVelocity - currentAngularVelocity);

        agent.AddTorque(agent.mass * difference * Vector3.up);
    }
Exemplo n.º 4
0
    void Awake()
    {
        //establish script connections
        mainComm    = GameObject.Find("ScriptHub").GetComponent <Main>();
        sessionComm = GameObject.Find("ScriptHub").GetComponent <SessionBehavior>();
        agentComm   = GameObject.Find("Agent").GetComponent <AgentInput>();

        //cache component lookup
        agentTrans = agentComm.transform;
    }
Exemplo n.º 5
0
 void Start()
 {
     bmAuto                   = new BallMovementAutomaton();
     agentComm                = GameObject.Find("Agent").GetComponent <AgentInput>();
     ballLaunced              = false;
     ballCollidedPaddle       = false;
     timeThreshold            = 25; //milliseconds
     timeOfLastCurrPosCapture = DateTime.Now;
     prevBx                   = 0F; currBx = 0F;
     currPos                  = BallUtils.GetBallPosition();
     posSamples               = new PositionSamples(currPos);
 }
Exemplo n.º 6
0
    public void ExecuteForces(AgentInput input)
    {
        float x = 0;
        float z = 0;

        Vector3 desired = Quaternion.AngleAxis(input.moveDirection * 45, -Vector3.up) * Vector3.right;

        desired = speedLimit * desired * Mathf.Clamp01(input.movePower);
        float   speedDifference = (desired - agent.velocity).magnitude;
        Vector3 forceDirection  = (desired - adjustCoefficient * agent.velocity).normalized;

        agent.AddForce(forceMultiplier * agent.mass * speedDifference * forceDirection);
    }
Exemplo n.º 7
0
    public void Execute(float timestep)
    {
        agentController.Execute(timestep);
        GunModule.ExecuteTimeStep(timestep);
        AgentInput input = agentController.GetInput();

        agentMovement.ExecuteForces(input);
        agentAim.ExecuteForces(input);
        if (input.shoot)
        {
            GunModule.TryShoot();
        }
    }
Exemplo n.º 8
0
        public override void SetChoice(ShopAgent agent, int input)
        {
            if (Enum.IsDefined(typeof(MainChoices), input))
            {
                var i = (MainChoices)input;

                AgentInput.ChangeScreen(agent, (EShopScreen)i);
            }
            else if (input >= 0)
            {
                Debug.Log(input);
            }
        }
Exemplo n.º 9
0
 /**
  * Static constructor.
  */
 public static void InitGeneralUtils()
 {
     BallUtils.InitBallUtilities();
     NetUtils.InitNetUtils();
     m_mainScript            = GameObject.Find("ScriptHub").GetComponent <Main>();
     m_agentScript           = GameObject.Find("Agent").GetComponent <AgentInput>();
     m_humanScript           = GameObject.Find("P1").GetComponent <HumanInput>();
     m_sessionScript         = GameObject.Find("ScriptHub").GetComponent <SessionBehavior>();
     m_menuScript            = GameObject.Find("ScriptHub").GetComponent <MenuBehavior>();
     m_ballScript            = GameObject.Find("Ball").GetComponent <BallBehavior>();
     m_dataScript            = GameObject.Find("ScriptHub").GetComponent <DataManger>();
     ROLE_SERVER             = 0;
     ROLE_CLIENT             = 1;
     HUMAN_ID                = 0;
     HUMAN_LEFT              = 2;
     HUMAN_RIGHT             = 3;
     AGENT_ID                = 1;
     AGENT_SKILL_RANDOM      = 0;
     AGENT_SKILL_NORMAL      = 1;
     AGENT_SKILL_FAST        = 2;
     RALLY_ID                = 2;
     UNASSIGNED              = 10;
     INPUT_KEYBOARD          = 0;
     INPUT_MOUSE             = 1;
     INPUT_HYDRA             = 2;
     BALL_RADIUS_LARGE       = 2;
     BALL_RADIUS_MEDIUM      = 1;
     BALL_RADIUS_SMALL       = 0.5F;
     PADDLE_SIZE_LARGE       = 9.0757605F;   //150%
     PADDLE_SIZE_MEDIUM      = 6.050507F;    //100%
     PADDLE_SIZE_SMALL       = 4.53788025F;  //75%
     PADDLE_WIDTH_MEDIUM     = 7.41716F;
     RASyN_IP                = "127.0.0.1";
     RASyN_PORT_MAP          = new Dictionary <string, int> ();
     PONG_SERVER_ID          = "PongServer";
     PONG_CLIENT1_ID         = "PongClient1";
     PONG_CLIENT2_ID         = "PongClient2";
     ASSIGNED_PONG_CLIENT_ID = "NULL";
     RASyN_PORT_MAP.Add(PONG_SERVER_ID, 19000);
     RASyN_PORT_MAP.Add(PONG_CLIENT1_ID, 19011);
     RASyN_PORT_MAP.Add(PONG_CLIENT2_ID, 19012);
     jss = new JsonSerializerSettings();
     jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
     jss.MissingMemberHandling = MissingMemberHandling.Ignore;
     //jss.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
     DRAW_TIMEOUT = 1000 * 60;         //60 second timeout in milliseconds
     BallUtils.InitBallUtilities();
     NetUtils.InitNetUtils();
     rallyCfg = new RallyConfiguration(Application.dataPath + "/Config/RallyConfiguration.json");
 }
Exemplo n.º 10
0
        private void CheckEconomy <TAgent, TScreen>(AgentInput <TAgent, TScreen> agentSystem,
                                                    ref EconomySystem <TAgent, TScreen> cachedEconomySystem,
                                                    TAgent agent) where TAgent : AgentScreen <TScreen> where TScreen : Enum
        {
            var economySystem = agentSystem.GetEconomySystem(agent);
            var refreshTime   = economySystem.GetRefreshTime(agent);

            if (economySystem != cachedEconomySystem || _cachedTime != refreshTime)
            {
                cachedEconomySystem = economySystem;
                _cachedShopSystem   = null;

                inputText.text = SetupText(economySystem, agent);
                _cachedTime    = refreshTime;
            }
        }
 public override void SetChoice(AdventurerAgent agent, int input)
 {
     if (Enum.IsDefined(typeof(AdventurerRequestInput), input))
     {
         AgentInput.ChangeScreen(agent, EAdventurerScreen.Main);
     }
     else
     {
         input -= 1;
         var requests = requestSystem.GetAllCraftingRequests();
         if (input >= 0 && input < requests.Count)
         {
             var requestTaker = agent.GetComponent <AdventurerRequestTaker>();
             requestTaker.TakeRequest(requests[input]);
         }
     }
 }
Exemplo n.º 12
0
 void Start()
 {
     agentComm        = GameObject.Find("Agent").GetComponent <AgentInput>();
     ballAuto         = new BallAutomaton();
     dormantPosition  = new Vector2(1000F, 1000F);
     startPosition    = new Vector2(-19.04773F, 81.49192F);
     activatePosition = new Vector2(-19.04773F, 41.20192F);
     MakeDormant();
     cachedWinner = GeneralUtils.UNASSIGNED;
     rand         = new System.Random(DateTime.Now.Millisecond);
     signs        = new bool[8] {
         true, false, true, false, true, false, true, false
     };
     ServerBallBehavior = false;
     ballHitCount       = 0;
     Cs          = 1.5F;
     Cm          = 2.5F;
     Cf          = 3.5F;
     endedInDraw = false;
 }
Exemplo n.º 13
0
    public override AgentInput Execute(StateInstance instance, BehaviourContext context)
    {
        var pursueInstance = instance as PursueStateInstance;

        pursueInstance.CurrentRepathTimer -= Time.deltaTime;

        if (pursueInstance.CurrentRepathTimer <= 0)
        {
            pursueInstance.CurrentRepathTimer = RepathTimer;
            context.SetTarget(pursueInstance.Target.transform.position);
        }

        var direction = (context.AiAgent.ProxyObject.nextPosition - context.Agent.transform.position).normalized;
        var result    = new AgentInput {
            MovementDirection = direction,
            RotationDirection = direction,
            Done = false
        };

        return(result);
    }
Exemplo n.º 14
0
        public override void SetChoice(AdventurerAgent agent, int input)
        {
            if (Enum.IsDefined(typeof(AgentAdventureInput), input))
            {
                AgentInput.ChangeScreen(agent, EAdventurerScreen.Main);
            }
            else
            {
                switch (GetAdventureStates(agent))
                {
                case AdventureStates.OutOfBattle:
                    StartBattle(agent, (BattleEnvironments)input);
                    break;

                case AdventureStates.InBattle:
                    var battleSystem = GetSubSystem(agent);
                    battleSystem.SetInput((BattleAction)input);
                    break;
                }
            }
        }
Exemplo n.º 15
0
    public override void AgentAction(float[] vectorAction, string textAction)
    {
        AgentInput agentInput = this.ConvertDiscreteVectorActionToAgentInput(vectorAction);

        PlayerInput playerInput = new PlayerInput(
            this.Player,
            agentInput.axis,
            !prevShootValue && agentInput.isShootPressed,
            !prevJumpValue && agentInput.isJumpPressed,
            prevJumpValue && !agentInput.isJumpPressed
            );

        this.horizontalAction.Perform(playerInput);
        this.jumpAction.Perform(playerInput);
        this.shootAction.Perform(playerInput);

        CollectRewards();

        this.prevJumpValue  = agentInput.isJumpPressed;
        this.prevShootValue = agentInput.isShootPressed;

        this.prevPlayerLifePoint = this.Player.lifePoint;
        this.prevEnemyLifePoint  = this.Enemy.lifePoint;
    }
Exemplo n.º 16
0
    public override AgentInput GetInput()
    {
        AgentInput input = new AgentInput(1f, 5 + 2 * Mathf.RoundToInt(Mathf.Sign(Mathf.Sin(2 * clock))), 0, false);

        return(input);
    }
    public override AgentInput GetInput()
    {
        AgentInput input = new AgentInput(humanInput.MovePower, humanInput.MoveDirection, humanInput.AimDirection, humanInput.Shoot);

        return(input);
    }
Exemplo n.º 18
0
 protected override void GoBack(ShopAgent agent)
 {
     AgentInput.ChangeScreen(agent, EShopScreen.Main);
 }
Exemplo n.º 19
0
 protected override void GoBack(AdventurerAgent agent)
 {
     AgentInput.ChangeScreen(agent, EAdventurerScreen.Main);
 }
Exemplo n.º 20
0
 void Start()
 {
     current = this;
     myAgent = GetComponent <MobileAgent>();
 }