Ejemplo n.º 1
0
 void Awake()
 {
     movement         = GetComponent <CharacterMovement> ();
     spriteController = GetComponent <SpriteControler> ();
     deathEvent       = new UnityEvent();
     hpUpdateEvent    = new HpUpdateEvent();
 }
Ejemplo n.º 2
0
 private void Awake()
 {
     if (CharacterCreationManager.CurrentCharacterInfo != null)
     {
         visuals = CharacterCreationManager.CurrentCharacterInfo;
         CharacterCreationManager.CurrentCharacterInfo = null;
     }
     Instance = this;
 }
        void Start()
        {
            player = GameLibOfMethods.player;
            spr    = FindObjectOfType <SpriteControler>();
            anim   = GameLibOfMethods.animator;
            rb     = player.GetComponent <Rigidbody2D>();
            grid   = NodeGridManager.GetGrid(PathFinding.Resolution.High);
            col    = player.GetComponent <Collider2D>();

            contactFilter = new ContactFilter2D();
            contactFilter.SetLayerMask(GameLibOfMethods.Instance.InteractablesLayer);
        }
Ejemplo n.º 4
0
        void Start()
        {
            spr = FindObjectOfType <SpriteControler>();

            player          = Player.gameObject;
            anim            = Player.anim;
            rb              = Player.rb;
            grid            = NodeGridManager.GetGrid(PathFinding.Resolution.High);
            col             = Player.col;
            playerTransform = Player.transform;

            contactFilter = new ContactFilter2D();
            contactFilter.SetLayerMask(LayerMask.GetMask("MouseOverCollider"));
        }
	// All sprite layers are created on load to minimize the impact of changing sprites
	/// <summary>Start this instance.</summary>
	void Start(){ 
		spriteInfo = GetComponentInParent<CreatePlayGrid>();
		attachedGridBlock = GetComponent<GridBlock>();

		//Initialize unit sprite.
		unitSprite = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		unitSprite.transform.SetParent(transform);
		unitSprite.transform.localPosition = new Vector3(0, 0, 0.1f);
		unitSprite.name = "Unit Sprite";

		//Initialize unit head sprite.
		headSprite = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		headSprite.transform.SetParent(transform);
		headSprite.transform.localPosition = new Vector3(0, 0, 0.2f);
		headSprite.name = "Head Sprite";

		//Initialize action sprites and use state.
		actionSprites = new SpriteControler[MAX_ACTIONS_ON_THIS_BLOCK];
		actionUsed = new bool[MAX_ACTIONS_ON_THIS_BLOCK];
		for(int x = 0; x < MAX_ACTIONS_ON_THIS_BLOCK; x++){
			actionSprites[x] = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
			actionSprites[x].transform.SetParent(transform);
			actionSprites[x].transform.localPosition = new Vector3(0, 0, 0.3f + x * 0.05f);
			actionSprites[x].name = "Action Sprite " + x;
		}

		//Initialize movement directions.
		movementDirections = new SpriteControler[4];
		string[] directionNames = { "up", "right", "down", "left" };
		for(int x = 0; x < 4; x++){
			movementDirections[x] = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
			movementDirections[x].transform.SetParent(transform);
			movementDirections[x].transform.localPosition = new Vector3(0, 0, 2.5f);

			//Rotating each movement arm.
			Quaternion rot = movementDirections[x].transform.localRotation;
			rot.eulerAngles = new Vector3(0.0f, 0.0f, 90.0f * x); //UNDONE check to see if rotation is correct
			movementDirections[x].transform.localRotation = rot;

			movementDirections[x].name = "Movment Direction " + directionNames[x];
			// Sprites for this controller are always the same.
			movementDirections[x].setSprite(spriteInfo.spritesAndColors.sprite_moveLine);
			//The color for this sprite is Alpha only.
			movementDirections[x].setColor(Color.clear);
		}

		//Initialize movement circle.
		movementCircle = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		movementCircle.transform.SetParent(transform);
		movementCircle.transform.localPosition = new Vector3(0, 0, 2.5f);
		movementCircle.name = "Movement Circle";

		//Initialize right connection.
		rightConnection = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		rightConnection.transform.SetParent(transform);
		rightConnection.transform.localPosition = new Vector3(conectionLocation, 0, 0.1f);
		rightConnection.name = "Right Conection";

		//Initialize above connection.
		aboveConnection = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		aboveConnection.transform.SetParent(transform);
		aboveConnection.transform.localPosition = new Vector3(0, -conectionLocation, 0.1f);
		aboveConnection.transform.Rotate(0f, 0f, 90f);
		aboveConnection.name = "Above Conection";

		//Initialize move sprite.
		moveSprite = Instantiate(spriteInfo.spritePrefab).GetComponent<SpriteControler>();
		moveSprite.transform.SetParent(transform);
		moveSprite.transform.localPosition = new Vector3(0, 0, 0.2f);
		moveSprite.name = "Move Sprite";

	}