Beispiel #1
0
 //Set references to the playerIcon, start necessary coroutines, etc.
 void InitializeNPCPanelController()
 {
     playerTransform   = InstanceDatabase.GetPlayerReference().transform;
     playerIcon        = transform.FindChild("FlippingItem").FindChild("Character").FindChild("Head").GetComponent <SpriteRenderer> ().sprite;
     mainSpeechControl = InstanceDatabase.GetLevelUIReference().transform.FindChild("Speech Bubble").GetComponent <SpeechControl> ();
     mainInteractablePanelController = InstanceDatabase.GetLevelUIReference().transform.FindChild("InteractablePanels").gameObject.GetComponent <InteractablePanelController> ();
     StartCoroutine("CheckForAndAttemptToSpeakToPlayer");
 }
Beispiel #2
0
    protected override void InitializeCharacter()
    {
        //Set required variables for the enemy to function.
        player = InstanceDatabase.GetPlayerReference().transform;

        InitializeEnemy();

        enemyControlCoroutine = EnemyControl();
        StartCoroutine(enemyControlCoroutine);
    }
Beispiel #3
0
 //Look into initializing this once the player comes into activation distance.
 //Has to be public for Thuk Guards.  Could be extended though.
 public virtual void InitializeHealthBar()
 {
     player        = InstanceDatabase.GetPlayerReference().transform;
     currentHealth = lifePoints;
     //Create panel
     uiHealthController = InstanceDatabase.GetLevelUIReference().transform.FindChild("Health Controller").gameObject.GetComponent <UIHealthController> ();
     //Initialize icon
     characterHeadSprite = transform.GetChild(0).GetChild(0).FindChild("Head").GetComponent <SpriteRenderer> ().sprite;
     //Start the coroutine that manages the active state of the health bar item.
     StartCoroutine(ControlHealthBarState());
 }
Beispiel #4
0
    //Initializing the NPC
    protected override void InitializeCharacter()
    {
        //Get required components.
        playerTransform = InstanceDatabase.GetPlayerReference().transform;
        playerInventory = InstanceDatabase.GetMainInventoryReference().GetComponent <InventoryFunctions> ();

        //Initialize the NPC before starting to walk around.
        InitializeNPC();
        //Create and start the coroutine.
        walkAroundCoroutine = WalkAround();
        StartCoroutine(walkAroundCoroutine);
    }
Beispiel #5
0
    IEnumerator MoveElevatorCoroutine()
    {
        //Make sure that the player moves with the elevator.
        InstanceDatabase.GetPlayerReference().transform.SetParent(transform.GetChild(0).FindChild("Elevator"));

        Animator anim = transform.GetChild(0).GetComponent <Animator> ();

        //Wait until the elevator is above the terrain.
        anim.SetTrigger("MoveUp");
        while (movedUp == false)
        {
            yield return(null);
        }

        //Make it look to the player that the elevator is still moving.
        anim.SetBool("AppearMoving", true);

        //Move the elevator below the terrain
        transform.position = new Vector3(transform.position.x, -35.13f, 0);

        transform.GetChild(0).FindChild("Elevator").transform.localPosition = Vector3.zero;

        transform.SetParent(null);

        //Create the level.  HAS TO BE PREINCREMENT NOT POSTINCREMENT
        LevelGenerator.instance.CreateLevel(++LevelGenerator.instance.currentLevel);

        yield return(new WaitForSeconds(6));

        //Move back up to the receiver.
        anim.SetBool("AppearMoving", false);
        anim.SetTrigger("MoveBack");

        //Unparent the player so that he/she will not be destroyed as well.
        while (movedToNextLevel == false)
        {
            yield return(null);
        }

        InstanceDatabase.GetPlayerReference().transform.SetParent(null);

        //Wait until the player leaves the level.
        int currentLevel = LevelGenerator.instance.currentLevel;

        while (LevelGenerator.instance.currentLevel == currentLevel)
        {
            yield return(null);
        }

        //Remove the elevator after the level changes so that they are not cluttering the scene.
        Destroy(gameObject);
    }
Beispiel #6
0
    /******************************* MOUSE CLICK MANAGER *******************************/

    public void OnPointerClick(PointerEventData data)
    {
        if (data.button == PointerEventData.InputButton.Left)
        {
            if (currentlyAssigned != null)
            {
                if (InstanceDatabase.GetPlayerReference().GetComponent <PlayerHealthPanelManager> ().GiveMoneyToPlayer(-currentlyAssigned.price))
                {
                    //Add the deassigned item to the player inventory and deduct the price of the item.
                    InstanceDatabase.GetMainInventoryReference().GetComponent <InventoryFunctions> ().AssignNewItemToBestSlot(new ResourceReferenceWithStack(currentlyAssigned.mainContentReference.uiSlotContent, 1));
                    ModifyCurrentItemStack(-1);
                }
            }
        }
    }
Beispiel #7
0
    //Called by LevelEventManager.
    void InitializeHotbarManager()
    {
        //Define player and hotbar slots.
        Transform slotParent = transform.FindChild("Slots");

        playerObject         = InstanceDatabase.GetPlayerReference();
        playerCostumeManager = playerObject.transform.FindChild("FlippingItem").FindChild("Character").GetComponent <PlayerCostumeManager>();
        hotbarSlots          = new HotbarSlotScript[slotParent.childCount];
        for (int i = 0; i < slotParent.childCount; i++)
        {
            hotbarSlots[i] = slotParent.GetChild(i).GetComponent <HotbarSlotScript> ();
            hotbarSlots[i].masterHotbarManager = this;
        }

        previouslyActiveSlot = -1;
        currentlyActiveSlot  = 0;

        StartCoroutine(CheckForActiveItemKey());
        StartCoroutine(CheckForPlayerDropItem());
    }
Beispiel #8
0
    public virtual void Initialize(Vector2 positionToFireToward, float velocity, float power)
    {
        playerObject = InstanceDatabase.GetPlayerReference();
        //Get the Rigidbody component so that physics can be used.
        rb2d = GetComponent <Rigidbody2D> ();

        //Calculate the heading to the fire location.
        float radianAngleToTarget = Mathf.Atan2((positionToFireToward.y - transform.position.y), (positionToFireToward.x - transform.position.x));
        float degreeAngleToTarget = radianAngleToTarget * Mathf.Rad2Deg;

        //Turn to the heading and move in that direction.
        transform.localRotation = Quaternion.Euler(new Vector3(0, 0, degreeAngleToTarget));
        rb2d.velocity           = new Vector2(velocity * Mathf.Cos(ScriptingUtilities.DegreesToRadians(degreeAngleToTarget)), velocity * Mathf.Sin(ScriptingUtilities.DegreesToRadians(degreeAngleToTarget)));

        //Set the strength of the arrow.
        this.power = power;

        //Start the coroutine that checks when the arrow should be destroyed (takes up memory space)
        StartCoroutine(DestroyIfDistanceFromPlayer());
    }
Beispiel #9
0
 public void Initialize()
 {
     player = InstanceDatabase.GetPlayerReference().transform;
     StartCoroutine(MoveTowardsPlayer());
 }