コード例 #1
0
    void Strategy_ClosestShoot()
    {
        t += Time.deltaTime;
        Vector3 closestPlanetPos = AIHelper.getClosestAlivePlanetPos(transform);

        planetManager.Command_SetRocketRotation(closestPlanetPos);
        float range = Vector3.Distance(transform.position, closestPlanetPos);

        if (t > gameConfig.shootMaximumDelay)
        {
            chooseStrategyRandomly();
            t = 0;
        }
        if (range < gameConfig.shootRange)
        {
            planetManager.Command_Shoot();
            chooseStrategyRandomly();
        }
    }
コード例 #2
0
    void Update()
    {
        //Ignore commands if it's on HUD
        if (MouseOvereGui(Input.mousePosition))
        {
            return;
        }

        //Virtual mouse WorldSpace position
        Vector3 virtWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        //Rocket Direction has changed
        planetManager.Command_SetRocketRotation(virtWorldPos);

        //Shoot Requested
        if (Input.GetMouseButtonDown(0))
        {
            planetManager.Command_Shoot();
        }
    }