示例#1
0
        // Use this for initialization
        void Start()
        {
            if (!dialogue)
            {
                dialogue = GameObject.Find("Yarn");
            }
            agent         = gameObject.GetComponent <NavMeshAgent>();
            agent.enabled = false;

            barrier = GetComponent <NavMeshObstacle>();
            myAnim  = GetComponent <Animator>();
        }
示例#2
0
 public void Init(float radius, float duration, Color color)
 {
     this.duration     = duration;
     this.radius       = radius;
     mat               = new Material(sphereMat);
     renderer          = GetComponent <MeshRenderer>();
     renderer.material = mat;
     mat.SetColor("_Color", color);
     SphereAppear();
     LeanTween.delayedCall(duration, SphereDisappear);
     obstacle = GetComponent <NavMeshObstacle>();
 }
示例#3
0
        public PetFollower(Transform target, NavMeshAgent agent, float maxDistance, float minDistance)
        {
            this.target        = target;
            this.distanceLimit = maxDistance;
            this.agent         = agent;

            //Add NavMeshObstacle component on the fly
            targetObstacle         = target.gameObject.AddComponent <NavMeshObstacle>() as NavMeshObstacle;
            targetObstacle.carving = true;
            targetObstacle.shape   = NavMeshObstacleShape.Capsule;
            targetObstacle.size   *= minDistance;
        }
示例#4
0
文件: IDoor.cs 项目: lulook23/WTG
    private void Start()
    {
        DoorStart();
        doorsAll.Add(this);
        usablesAll.Add(this);
        NavMeshObstacle obs  = GetComponent <NavMeshObstacle> ();
        BoxCollider     coll = gameObject.AddComponent <BoxCollider> ();

        coll.center      = obs.center;
        coll.size        = obs.size;
        gameObject.layer = LayerMask.NameToLayer("Door");
    }
示例#5
0
 protected override void Awake()
 {
     base.Awake();
     animator = GetComponentInChildren <Animator>();
     weapon   = GetComponentInChildren <GoblinDagger>();
     weapon.Initialize(animator, this, damage);
     GetComponentInChildren <EnemyWeaponDelegate>().SetWeapon(weapon);
     obstacle         = GetComponent <NavMeshObstacle>();
     obstacle.enabled = false;
     health           = GetComponent <EnemyHealth>();
     healthSnapshot   = health.GetCurrentHealth();
 }
示例#6
0
    protected virtual void Awake()
    {
        // get components
        healthText = GetComponentInChildren <Text>();
        if (healthText)
        {
            if (health > maxHealth)
            {
                health = maxHealth;
            }
            RefreshHealthText();
        }

        spriteRenderer = GetComponent <SpriteRenderer>();

        teamColor = transform.GetChild(0).GetComponent <SpriteRenderer>();
        if (!teamColor)
        {
            Debug.LogWarning("Can't find team color object of " + name);
        }

        normalColor = spriteRenderer.color;
        dimmedColor = normalColor * 0.8f;

        obstacle = GetComponent <NavMeshObstacle>();
        if (!obstacle)
        {
            obstacle         = gameObject.AddComponent <NavMeshObstacle>();
            obstacle.carving = true;
        }

        hitParticles = GetComponentInChildren <ParticleSystem>();
        // ///////////////////////////////////////////////////

        // create terrain mask
        foreach (TerrainType terrain in availableTerrains)
        {
            terrainMask |= (1 << NavMesh.GetAreaFromName(terrain.ToString()));
        }

        // place object on NavMesh
        NavMeshHit navMeshHit = new NavMeshHit();

        if (NavMesh.SamplePosition(transform.position, out navMeshHit, 0.5f, terrainMask))
        {
            transform.position    = navMeshHit.position;
            transform.eulerAngles = new Vector3(90, 0, 0);
        }
        else
        {
            Debug.LogWarning("Can't place '" + name + "' (" + GetType() + ") object on a NavMesh!");
        }
    }
    // Use this for initialization
    void Start()
    {
        NavMeshObstacle temp = gameObject.AddComponent <NavMeshObstacle>();

        temp.carving = true;

        for (int i = 0; i < transform.childCount; i++)
        {
            NavMeshObstacle loopTemp = transform.GetChild(i).gameObject.AddComponent <NavMeshObstacle>();
            loopTemp.carving = true;
        }
    }
示例#8
0
        /* Functions */

        private void Awake()
        {
            this.mNavMeshAgent    = this.GetComponent <NavMeshAgent>();
            this.mNavMeshObstacle = this.GetComponent <NavMeshObstacle>();
            ObstacleNow();

            this.mAdjustTimeTrigger = this.GetComponent <JCS_AdjustTimeTrigger>();

            mAdjustTimeTrigger.actions = DoAI;

            this.mStartingPosition = this.transform.position;
        }
示例#9
0
 protected override void Start()
 {
     base.Start();
     instanceID         = GetInstanceID();
     rend               = GetComponentInChildren <Renderer>();
     obstacle           = GetComponent <NavMeshObstacle>();
     marker             = GetComponentInChildren <SpriteRenderer>();
     marker.enabled     = false;
     hpbarImage.enabled = false;
     hpBar              = hpbarImage.GetComponent <HPBar>();
     resoManager        = GameObject.FindGameObjectWithTag("Player").GetComponent <ResourceManager>();
 }
示例#10
0
    public void Place()
    {
        meshRenderer.material.color = Color.white;
        buildingCollider.isTrigger  = false;
        NavMeshObstacle navMeshObstacle = gameObject.AddComponent <NavMeshObstacle>();

        navMeshObstacle.carving = true;

        placed = true;
        OnPlaced();

        Build();
    }
示例#11
0
 protected override void Awake()
 {
     base.Awake();
     navigator.enabled = false;
     animator          = GetComponentInChildren <Animator>();
     animator.SetFloat("BreathSpeedMultiplier", breathSpeedMultiplier);
     animator.SetFloat("SmashSpeedMultiplier", smashSpeedMultiplier);
     caveAbilities    = GetComponentInChildren <CaveAbilities>();
     obstacle         = GetComponent <NavMeshObstacle>();
     obstacle.enabled = true;
     GetComponent <EnemyHealth>().SetImmune(true);
     audioPlayer = gameObject.AddComponent <AudioSource>();
 }
    private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.name.Equals("Runner") && !isClose)
        {
            prisoner = col.gameObject;
            Debug.Log("collision with runner");
            isClose = true;

            NavMeshObstacle obstacle = gameObject.AddComponent <NavMeshObstacle>();
            obstacle.size = new Vector3(1.2f, 1.2f, 1.2f);
            transform.parent.GetComponent <BadGuyBehavior>().state = 4;
        }
    }
示例#13
0
 // Use this for initialization
 void Start()
 {
     body     = GetComponent <Rigidbody>();
     obstacle = GetComponent <NavMeshObstacle>();
     if (isLocked)
     {
         Lock();
     }
     else
     {
         Unlock();
     }
 }
    void Start()
    {
        shooting = GetComponentInChildren <ShootingController> ();
        shooting.SetEnabled(false);

        if (automatic)
        {
            SetupTarget();
        }

        obstacle         = GetComponent <NavMeshObstacle> ();
        obstacle.enabled = false;
    }
示例#15
0
    // Start is called before the first frame update
    void Start()
    {
        obstacle     = GetComponent <NavMeshObstacle>();
        meshRenderer = GetComponent <MeshRenderer>();
        rigidBody    = GetComponent <Rigidbody>();

        openingTimer = timeToOpen;
        timerEnabled = false;

        targetRotation = closedRotation = transform.rotation;
        openRotation   = transform.rotation * Quaternion.Euler(Vector3.up * degreesToOpen);
        audioSource    = GetComponent <AudioSource>();
    }
示例#16
0
 void Start()
 {
     lostWordS    = GetComponent <AudioSource>();
     playedStolen = false;
     isBaked      = false;
     closeWall    = false;
     isWord       = true;
     Player       = GameObject.FindGameObjectWithTag("Player");
     house        = GameObject.FindGameObjectWithTag("House");
     //surface = FindObjectOfType<NavMeshSurface>();
     houseO = FindObjectOfType <NavMeshObstacle>();
     Respawn();
 }
示例#17
0
    public void Place()
    {
        SoundManager.instance.PlayDrop();
        transform.position = player.transform.GetChild(1).transform.position;
        transform.parent   = null;
        BoxCollider boxCollider = GetComponent <BoxCollider>();

        boxCollider.enabled = true;
        NavMeshObstacle navMeshObstacle = GetComponent <NavMeshObstacle>();

        navMeshObstacle.enabled = true;
        player.GetComponent <PlayerController>().SetCarriedGO(null);
    }
示例#18
0
        /// <summary>
        /// Add and configure a NavMesh Obstacle. This just needs to be on the player; NPCs with a NavMeshAgent
        /// use that for avoidance
        /// </summary>
        /// <param name="rMotionController"></param>
        /// <returns></returns>
        public static NavMeshObstacle AddNavMeshObstacle(MotionController rMotionController)
        {
            NavMeshObstacle lNavMeshObstacle = rMotionController.GetOrAddComponent <NavMeshObstacle>();

            if (lNavMeshObstacle == null)
            {
                return(null);
            }
            lNavMeshObstacle.shape  = NavMeshObstacleShape.Capsule;
            lNavMeshObstacle.center = Vector3.up;

            return(lNavMeshObstacle);
        }
示例#19
0
 public static void CopyFrom(this NavMeshObstacle self, NavMeshObstacle tarObstacle)
 {
     self.carveOnlyStationary     = tarObstacle.carveOnlyStationary;
     self.carving                 = tarObstacle.carving;
     self.carvingMoveThreshold    = tarObstacle.carvingMoveThreshold;
     self.carvingTimeToStationary = tarObstacle.carvingTimeToStationary;
     self.center   = tarObstacle.center;
     self.height   = tarObstacle.height;
     self.radius   = tarObstacle.radius;
     self.shape    = tarObstacle.shape;
     self.size     = tarObstacle.size;
     self.velocity = tarObstacle.velocity;
 }
示例#20
0
 protected override void Start()
 {
     base.Start();
     instanceID         = GetInstanceID();
     anim               = GetComponentInChildren <Animator>();
     agent              = GetComponent <NavMeshAgent>();
     agent.enabled      = false;
     obstacle           = GetComponent <NavMeshObstacle>();
     marker             = GetComponentInChildren <SpriteRenderer>();
     marker.enabled     = false;
     hpbarImage.enabled = false;
     hpBar              = hpbarImage.GetComponent <HPBar>();
 }
示例#21
0
        //**************************
        //END DETERMINE OBJECTS IN RANGE
        //**************************

        //**************************
        //BEGIN VARIOUS GENERAL CALCULATIONS
        //**************************

        public static bool DetermineIfNearNavObstacle(Vector3 seekerPoint, float range)
        {
            Collider[] collidersInRange = Physics.OverlapSphere(seekerPoint, range);
            foreach (Collider col in collidersInRange)
            {
                NavMeshObstacle obstacle = col.gameObject.GetComponentInParent <NavMeshObstacle> ();
                if (obstacle != null)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#22
0
    public void Init(HumanEvent humanEvent)
    {
        // 初始化引用
        this.humanEvent = humanEvent;
        animator        = GetComponentInChildren <Animator>();
        BornPos         = transform.position; // 记录出生点位置(HOME)
        FluentText.InitPanel(transform, FluentText.transform.position - transform.position);
        Obstacle = GetComponent <NavMeshObstacle>();
        SwitchAgentObstacle(true);

        // 开始执行任务
        mission = StartCoroutine(GO());
    }
示例#23
0
 private void Start()
 {
     genThread = new GenerationThread();
     genThread.Start();
     genThread.Init(this, OnGenerationFinished, continentValueToAmplification);
     if (randomSeed)
     {
         seed = Random.Range(0, int.MaxValue);
     }
     townGen.OnTownGenerationCompleteEvent += OnTownGenerationComplete;
     waterObstacle = water.GetComponent <NavMeshObstacle>();
     InitNavMeshSettings();
 }
示例#24
0
    void Start()
    {
        playerPos   = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
        playerStats = playerPos.gameObject.GetComponent <PlayerStatus>();

        pathFinding = GetComponent <NavMeshAgent>();
        obstacle    = GetComponent <NavMeshObstacle>();

        obstacle.enabled = false;

        ScaleZombie();
        StartCoroutine(UpdatePath());
    }
示例#25
0
 protected override void Awake()
 {
     base.Awake();
     building         = this;
     spawnPoint       = transform.position;
     navObstacle      = GetComponent <NavMeshObstacle> ();
     activeModel      = GetComponentInChildren <ActiveBuildingModel>();
     destroyedModel   = GetComponentInChildren <DestroyedBuildingModel>(true);
     spawner          = GetComponentInChildren <Spawner>();
     maxBuildProgress = paramManager.MaxHitPoints;
     StoreOriginalMaterials();
     buildingState = new VirtualStateB(building, false);
 }
示例#26
0
    private void OnMouseDown()
    {
        List <PlayerPlanet> attackers = GameController.S.attackers;

        foreach (PlayerPlanet attacker in attackers)
        {
            attacker.SpawnShips(gameObject.transform);
        }

        NavMeshObstacle navMesh = GetComponent <NavMeshObstacle>();

        navMesh.enabled = false;
    }
 void Start()
 {
     if (!pivot)
     {
         enabled = false;
     }
     navMeshObstacle = GetComponentInChildren <NavMeshObstacle>();
     if (navMeshObstacle)
     {
         navMeshObstacle.enabled = false;
         navMeshObstacle.carving = true;
     }
 }
示例#28
0
//---------------------------------------------------------------------MONO METHODS:
    void Start()
    {
        individualMove  = false;
        parent          = Parent.transform;
        individualSpeed = FlockZombie.Instance.Speed;
        frequency       = FlockZombie.Instance.MovementFrequency;
        pos1            = FlockZombie.Instance.RandomOffset();
        pos2            = FlockZombie.Instance.RandomOffset();
        Dropped         = false;
        box             = GetComponent <BoxCollider>();
        sphere          = GetComponent <CapsuleCollider>();
        obstacle        = child.GetComponent <NavMeshObstacle>();
    }
示例#29
0
    public void CmdSpawnObject(int buildingSpawnIndex, Vector3 position, Quaternion rotation)
    {
        Debug.Log("Spawning rubble");
        //Copying the components of the building to the rubble
        GameObject  rubble           = NetworkManager.singleton.spawnPrefabs[rubbleIndex];
        GameObject  building         = NetworkManager.singleton.spawnPrefabs[buildingSpawnIndex];
        GameObject  buildingGraphics = buildingSystem.buildingGroups.buildings[buildingSystem.selectedBuildingIndex].graphics;
        BoxCollider buildingCollider = building.GetComponent <BoxCollider> ();

        buildingCollider.size = buildingGraphics.transform.localScale;         // + buildingGroups.buildings[selectedBuildingIndex].addedColliderScale;
        Vector3 rubbleSize = rubble.transform.localScale;

        rubbleSize.x = buildingCollider.size.x;
        rubbleSize.z = buildingCollider.size.z;
        rubble.transform.localScale = rubbleSize;

        NavMeshObstacle navMeshObstacle = rubble.GetComponent <NavMeshObstacle> ();
        Vector3         obstacleSize    = new Vector3(1, 1, 1);

        obstacleSize.x      -= Mathf.Clamp(obstacleSizeCut, 1, int.MaxValue) / 10f;
        obstacleSize.y      += Mathf.Clamp(obstacleHeightAdd / 100f, 2, int.MaxValue);
        obstacleSize.z      -= Mathf.Clamp(obstacleSizeCut, 1, int.MaxValue) / 10f;
        navMeshObstacle.size = obstacleSize;

        //Assign data for the rubble
        ConstructionInteractable constructionInteractable = rubble.GetComponent <ConstructionInteractable> ();

        constructionInteractable.constructionTime = buildingSystem.buildingGroups.buildings[buildingSystem.selectedBuildingIndex].constructionTime;
        constructionInteractable.buildingIndex    = buildingSystem.selectedBuildingIndex;
        constructionInteractable.team             = team;
        if (rubbleSize.x > rubbleSize.z)
        {
            constructionInteractable.influenceRadius = rubbleSize.x + 1;
        }
        else
        {
            constructionInteractable.influenceRadius = rubbleSize.z + 1;
        }
        constructionInteractable.playerObject = buildingSystem.PO;
        //Instantiating the rubble
        rubble = Instantiate(rubble, position, rotation);

        NetworkIdentity ni = rubble.GetComponent <NetworkIdentity> ();

        Debug.Log("Player Object :: --Spawning Unit");
        NetworkServer.Spawn(rubble);
        bool ToF = rubble.GetComponent <NetworkIdentity> ().AssignClientAuthority(GetComponent <NetworkIdentity> ().connectionToClient);

        Debug.Log("Player Object :: --Unit Spawned : " + ToF);
        RpcAssignObject(ni);
    }
示例#30
0
 private void Awake()
 {
     audioSource      = GetComponent <AudioSource>();
     damageCastOrigin = transform.Find("DamageCaster").transform;
     nma                     = GetComponent <NavMeshAgent>();
     navMeshObstacle         = GetComponent <NavMeshObstacle>();
     navMeshObstacle.enabled = false;
     lb_animator             = transform.Find("LowerBody").GetComponentInChildren <Animator>();
     ub_animator             = transform.Find("UpperBody").GetComponentInChildren <Animator>();
     playerGO                = GameObject.FindGameObjectWithTag("Player");
     playerController        = playerGO.GetComponent <PlayerController>();
     lb_animator.SetBool("walking", false);
     CurrentHealth = MaxHealth;
 }