// Use this for initialization
 void Start()
 {
     TownWall = GameObject.Find ("Helms Deep");
     wallCode = TownWall.GetComponent <WallScript>();
     // Setting the navigation to autopath the enemies to the wall
     OriginHP = HP;
     // Getting position of wall
     wall = GameObject.Find ("enemyDestination");
     wallPlace = wall.GetComponent<Transform>();
     // Getting NavMesh component
     enemy = GetComponent<NavMeshAgent>();
     enemy.enabled = true;
     // Setting destination of enemy
     newDestination = new Vector3(wallPlace.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
     enemy.destination = newDestination;
 }
    // To find which wall is the hob attached to.
    void HobWall()
    {
        Vector3 hobWallPoint = Vector3.zero;

        foreach (GameObject cabinet in CabinetManager.Instance.cabinetsInScene) {
            if(cabinet.GetComponent<CabinetScript>()._typeOfCabinet == CabinetScript.TypeOfCabinet.Hob)
            {
                hobOnWall = cabinet.GetComponent<CabinetScript>().attachedToWall.GetComponent<WallScript>();

        //				print ("the hob is atached to "+hobOnWall.name);

                if(hobOnWall.name == "topWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x,cabinet.transform.position.y,cabinet.transform.position.z + cabinet.GetComponent<CabinetScript>().boundExtends.z);
                    isHobAlongTheWidth = true;
                }

                if(hobOnWall.name == "bottomWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x,cabinet.transform.position.y,cabinet.transform.position.z - cabinet.GetComponent<CabinetScript>().boundExtends.z);
                    isHobAlongTheWidth = true;
                }

                if(hobOnWall.name == "leftWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x - cabinet.GetComponent<CabinetScript>().boundExtends.x,cabinet.transform.position.y,cabinet.transform.position.z);
                    isHobAlongTheWidth = false;
                }

                if(hobOnWall.name == "rightWall")
                {
                    hobWallPoint = new Vector3(cabinet.transform.position.x + cabinet.GetComponent<CabinetScript>().boundExtends.x,cabinet.transform.position.y,cabinet.transform.position.z);
                    isHobAlongTheWidth = false;
                }

                distanceFromInitailVertToHob = Vector3.Distance (hobOnWall.initialVertex.transform.position,hobWallPoint);
                distanceFromFinalVertToHob = Vector3.Distance (hobOnWall.finalVertex.transform.position,hobWallPoint);
            }
        }
    }
Beispiel #3
0
	void Awake(){
		Wall = GetComponent<WallScript> ();
		MovingLine = new List <Vector2[]> ();
	}
    /*
	 * 	Start / Update
	 */
    public void Init(Transform parent, WallScript wall, string name){
		this.transform.SetParent(parent, false);
        this.CurrentState = ObjectState.Idle;
        this.draggableObjectName = name;
        this.isTriggered = false;
        //this.scaleImmediatly = false;
        this.wall = wall;
		this.layer = -1;

        var collider = GetComponent<BoxCollider2D>();
        collider.isTrigger = true;
    }