コード例 #1
0
 // Use this for initialization
 void Start()
 {
     text          = this.GetComponent <Text>();
     bt            = this.GetComponent <PandaBehaviour>();
     rectTransform = this.GetComponent <RectTransform>();
     bt.enabled    = false;
 }
コード例 #2
0
    private void Start()
    {
        // get the car controller
        m_Drone         = GetComponent <DroneController>();
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
        pbTree          = GetComponent <PandaBehaviour>();

        // note that both arrays will have holes when objects are destroyed
        // but for initial planning they should work
        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag       = "Red";
            attackDirection = Vector3.right;
        }
        else
        {
            enemy_tag       = "Blue";
            attackDirection = Vector3.left;
        }
        friends = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies = GameObject.FindGameObjectsWithTag(enemy_tag);

        initAcc();
        ball           = GameObject.FindGameObjectWithTag("Ball");
        myDefencePoint = new Vector3(120f, 0f, 100f);
        for (playerNum = 0; friends[playerNum].transform != m_Drone.transform; playerNum++)
        {
        }
        time = Time.fixedDeltaTime * 50f;
        //FixedUpdate();
    }
コード例 #3
0
    private void Start()
    {
        pandaBT = GetComponent <PandaBehaviour>();
        rb      = GetComponent <Rigidbody>();

        // get the drone controller
        m_Drone         = GetComponent <DroneController>();
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag = "Red";
        }
        else
        {
            enemy_tag = "Blue";
        }

        friends = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies = GameObject.FindGameObjectsWithTag(enemy_tag);

        ball = GameObject.FindGameObjectWithTag("Ball");

        goalie = friends[0];
    }
コード例 #4
0
    // Start is called before the first frame update
    void Start()
    {
        if (escarabajo)
        {
            this.vida      = 30;
            this.daño      = 3;
            this.velocidad = 1.0f;
        }
        else
        {
            this.vida      = 12;
            this.daño      = 2;
            this.velocidad = 2.0f;
        }

        this.zonaDondeEsta = 1;
        pb           = this.gameObject.GetComponent <PandaBehaviour>();
        agente       = this.gameObject.GetComponent <NavMeshAgent>();
        agente.speed = this.velocidad;
        this.siguientePosicionExplorar = Vector3.zero;
        hormigueroDentro   = GameObject.FindObjectOfType <Floor>();
        tiempoEntreAtaques = tiempoEntreAtaquesMax;
        reina = GameObject.FindObjectOfType <Reina>();

        if (escarabajo)
        {
            agente.avoidancePriority = 0;
        }
    }
コード例 #5
0
    private void Start()
    {
        id = counter;
        counter++;
        if (id == 0)
        {
            GoalKeeper = true;
        }
        if (id == 1)
        {
            Chaser = true;
        }
        if (id == 2)
        {
            Center = true;
        }

        ball_mass       = 1f;
        drone_mass      = 1000f;
        drone_max_speed = 15f;
        ball_radius     = 2.1f;
        drone_radius    = 1.4f;
        field_width     = 180f;

        Debug.Log("Start");
        myPandaBT = GetComponent <PandaBehaviour>();
        // get the car controller
        m_Drone = GetComponent <DroneController>();


        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        // note that both arrays will have holes when objects are destroyed
        // but for initial planning they should work
        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag = "Red";
        }
        else
        {
            enemy_tag = "Blue";
        }

        friends = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies = GameObject.FindGameObjectsWithTag(enemy_tag);
        Debug.Log("Friends: " + friends.Length + " Enemies: " + enemies.Length);
        ball          = GameObject.FindGameObjectWithTag("Ball");
        ball_position = ball.transform.position;



        System.Random rand = new System.Random();
        manager.AddDrone(m_Drone, base_velocity, other_goal.transform.position);
        my_path = new List <Vector3>();
        my_path.Add(other_goal.transform.position);
    }
コード例 #6
0
    protected override void Destroy(float delay = 0)
    {
        navAgent.enabled = false;
        isChasing        = false;
        PandaBehaviour panda = GetComponent <PandaBehaviour>();

        panda.Reset();
        base.Destroy(delay);
    }
コード例 #7
0
    // Start is called before the first frame update
    void Start()
    {
        player    = GameObject.FindGameObjectWithTag("Player");
        tree      = GetComponent <PandaBehaviour>();
        navigator = GetComponent <Navigator>();

        mask = LayerMask.GetMask("Player", "Walls");

        makePatrolPath();
    }
コード例 #8
0
 void Start()
 {
     pb                 = this.gameObject.GetComponent <PandaBehaviour>();
     hormiga_sprite     = this.GetComponentInChildren <SpriteRenderer>();
     hormiga_colisiones = this.GetComponentInChildren <MeshCollider>();
     link               = FindObjectOfType <OffMeshLink>();
     speed              = agent.speed;
     haEntradoAlCamino  = false;
     linkMultiplayer    = 2;
 }
コード例 #9
0
ファイル: init.cs プロジェクト: avielBS/AR-Stanga-Game
    // Update is called once per frame
    void Update()
    {
        if (my_target.CurrentStatus != TrackableBehaviour.Status.NO_POSE && counter == 0)
        {
            //gameObject.AddComponent<PandaBehaviour>();
            PandaBehaviour p = gameObject.GetComponent <PandaBehaviour>();
            p.enabled = true;


            counter++;
        }
    }
コード例 #10
0
 // Change the BT to run by the PandaBehaviour component.
 // The file name servers as the key in the dictionary to retrieve the BT definition.
 public void changeBT(GameObject character, string bt_id)
 {
     try
     {
         PandaBehaviour component = character.GetComponent <PandaBehaviour>();
         component.Compile(BT_dic[bt_id]);
     }
     catch (Exception e)
     {
         Debug.Log("EXCEPTION: " + e);
     }
 }
コード例 #11
0
    // Start is called before the first frame update
    void Start()
    {
        panda_bt = GetComponent <PandaBehaviour>();
        rb       = GetComponent <Rigidbody2D>();
        ctrl     = GetComponent <CharacterController>();

        team_tag = gameObject.tag;
        opp_tag  = team_tag == "red_team" ? "blue_team" : team_tag == "blue_team" ? "blue_team" : "invalid";

        ball         = UnityEngine.GameObject.Find("ball");
        team_players = GameObject.FindGameObjectsWithTag(team_tag);
        opp_players  = GameObject.FindGameObjectsWithTag(opp_tag);
    }
コード例 #12
0
 void Awake()
 {
     aiUnit                = GetComponent <CharacterControl> ();
     animator              = GetComponentInChildren <Animator> ();
     pandaTree             = GetComponent <PandaBehaviour> ();
     team                  = aiUnit.CharacterData.Team;
     LastGetHitTime        = Mathf.NegativeInfinity;
     LastTargetAttackTime  = Mathf.NegativeInfinity;
     LastTargetExecuteTime = Mathf.NegativeInfinity;
     LastTargetDodgeTime   = Mathf.NegativeInfinity;
     LastTargetGuardTime   = Mathf.NegativeInfinity;
     enemyTarget           = null;
     AIAgentManager.Instance.TotalAIAgent.Add(this);
 }
コード例 #13
0
    IEnumerator SpawnEnemyFromRope()
    {
        yield return(new WaitForSeconds(1f));

        SpawnRect spawnRect = playerEntity.spawnRect;

        spawnRect.rect.x += playerEntity.moveVelocity.x;
        spawnRect.rect.y += playerEntity.moveVelocity.z;

        Vector3 spawnPos = mapGen.GetSpawnPositionInRect(spawnRect) + Vector3.up;

        if (spawnPos != (Vector3.one * -1))//-1 Vector means the map wasn't able to find any available position, so just return and train again after 1 sec
        {
            Vector3   startSpawnPos = spawnPos + Vector3.up * 20f;
            Transform enemyT        = PoolManager.instance.ReuseObject(enemy.gameObject, startSpawnPos, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)).transform;
            enemyT.GetComponent <Enemy>().SetCharacteristics(currentWave.moveSpeed, currentWave.hitsToKillPlayer, currentWave.enemyHealth);
            Transform rope = ((Rope)Instantiate(enemyT.GetComponent <Enemy>().rope, startSpawnPos, Quaternion.identity)).transform;

            PandaBehaviour panda = enemyT.GetComponent <PandaBehaviour>();
            panda.enabled = false;

            float percent      = 0f;
            float ropeVelocity = 1 / 0.3f;
            while (percent < 1)
            {
                percent      += ropeVelocity * Time.deltaTime;
                rope.position = Vector3.Lerp(startSpawnPos, spawnPos, percent);
                yield return(null);
            }

            percent = 0;
            float climbDownVel = 1 / 1.5f;
            while (percent < 1)
            {
                percent        += climbDownVel * Time.deltaTime;
                enemyT.position = Vector3.Lerp(startSpawnPos, spawnPos, percent);
                yield return(null);
            }

            Enemy spawnedEnemy = enemyT.GetComponent <Enemy>();

            spawnedEnemy.OnDeath += OnEnemyDeath;
            enemyT.position       = spawnPos;
            panda.enabled         = true;
            spawnedEnemy.StartChase();
            Destroy(rope.gameObject, 2);
        }
    }
コード例 #14
0
    public void CheckIfPandaMarginIsHit(PandaBehaviour panda)
    {
        Transform      pandaTransform      = panda.transform;
        SpriteRenderer pandaSpriteRenderer = panda.gameObject.GetComponent <SpriteRenderer>();

        if (pandaTransform.position.x < -screenDimensions.x + pandaTransform.localScale.x / 2 ||
            pandaTransform.position.x > screenDimensions.x - pandaTransform.localScale.x / 2)
        {
            panda.speedX *= -1;

            if (panda.speedX > 0)
            {
                pandaSpriteRenderer.flipX = false;
            }
            else
            {
                pandaSpriteRenderer.flipX = true;
            }
        }
    }
コード例 #15
0
    public virtual void Awake()
    {
        // useful
        targetPlayer = GameObject.FindWithTag("Player").transform;
        audioManager = FindObjectOfType <AudioManager>();
        pandaBT      = GetComponent <PandaBehaviour>();
        rb           = GetComponent <Rigidbody2D>();
        old_pos      = transform.position.x;

        //fov
        fovStartPoint = getChildGameObject(this.gameObject, "FovStartPoint").transform;
        if (fovStartPoint == null)
        {
            Debug.LogWarning("Null FovStartPoint");
        }
        aimDir      = new Vector3(1, 1f, 0f); // aim direction(field of view init) best leave it like this
        fieldOfView = Instantiate(pfFieldOfView, null).GetComponent <FieldOfView>();
        fieldOfView.SetFoV(fov);
        fieldOfView.SetViewDistance(viewDistance);

        //combat
        currentHealth = maxHealth;
        try
        {
            fireAnimHitByTorchPoint = getChildGameObject(this.gameObject, "FireHitByTorchPoint").transform;
        }
        catch
        {
            Debug.LogWarning("FireHitByTorchPoint is null");
        }

        attackPoint = getChildGameObject(this.gameObject, "AttackPoint").transform;
        if (attackPoint == null)
        {
            Debug.LogWarning("Null AttackPoint");
        }

        //Handlers
        animationHandler = getChildGameObject(this.gameObject, graphicsName).GetComponent <AnimationHandler>();
        soundHandler     = getChildGameObject(this.gameObject, graphicsName).GetComponent <SoundHandler>();
    }
コード例 #16
0
    private void Start()
    {
        pandaBT = GetComponent <PandaBehaviour>();
        rb      = GetComponent <Rigidbody>();

        // get the drone controller
        m_Drone         = GetComponent <DroneController>();
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag = "Red";
        }
        else
        {
            enemy_tag = "Blue";
        }

        friends = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies = GameObject.FindGameObjectsWithTag(enemy_tag);

        ball = GameObject.FindGameObjectWithTag("Ball");

        // Set the friend closet to the own goal to be the goalie.
        float disToOwnGoal_sqr = float.PositiveInfinity;

        foreach (var friend in friends)
        {
            float dis_sqr = (friend.transform.position - own_goal.transform.position).sqrMagnitude;
            if (dis_sqr < disToOwnGoal_sqr)
            {
                disToOwnGoal_sqr = dis_sqr;
                goalie           = friend;
            }
        }
    }
コード例 #17
0
    Vector3 dir = Vector3.one; private void Start()
    {
        ball_mass       = 1f;
        drone_mass      = 1000f;
        drone_max_speed = 10f;
        ball_radius     = 2.1f;
        drone_radius    = 1f;

        id = counter;
        counter++;
        myPandaBT = GetComponent <PandaBehaviour>();
        // get the car controller
        m_Drone         = GetComponent <DroneController>();
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();


        // note that both arrays will have holes when objects are destroyed
        // but for initial planning they should work
        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag = "Red";
        }
        else
        {
            enemy_tag = "Blue";
        }

        friends = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies = GameObject.FindGameObjectsWithTag(enemy_tag);

        ball = GameObject.FindGameObjectWithTag("Ball");


        // Plan your path here
        // ...
    }
    private void Start()
    {
        // get the car controller

        pandaBT         = GetComponent <PandaBehaviour>();
        m_Drone         = GetComponent <DroneController>();
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        // Set the tags for friends and enemies
        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag = "Red";
        }
        else
        {
            enemy_tag = "Blue";
        }

        friends     = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies     = GameObject.FindGameObjectsWithTag(enemy_tag);
        stadiumSize = Vector3.Distance(own_goal.transform.position, other_goal.transform.position);
        ball        = GameObject.FindGameObjectWithTag("Ball");
    }
コード例 #19
0
 // Use this for initialization
 void Start()
 {
     CharacterBT = GetComponent <PandaBehaviour>();
 }