示例#1
0
    //Swapping Method for UI Ability elements
    public void swapIcons(AbilityUI other)
    {
        PKMNEntity temp = other.getFighter();

        other.setUp(fighter);
        this.setUp(temp);
    }
    //Private helper method that allows a delay before having the assistFighter become the main selectedFighter
    //  Pre: assistFighter is currently the only party member that is alive
    IEnumerator assistToSelected()
    {
        PKMNEntity prevFighter = selectedFighter;

        selectedFighter = assistFighter;
        animator        = selectedFighter.GetComponent <Animator>();
        player          = selectedFighter.GetComponent <Transform>();

        yield return(new WaitForSeconds(DEATH_WAIT));

        //Switch UI elements
        secMoveIndex = 0;
        mainSwapper.switchAbilities(secMoveIndex);
        swapUIBars(selectedFighter, prevFighter);
        abilityUIMap[selectedFighter].swapIcons(abilityUIMap[prevFighter]);

        //Switches fighter mappings
        AbilityUI temp = abilityUIMap[selectedFighter];

        abilityUIMap[selectedFighter] = abilityUIMap[prevFighter];
        abilityUIMap[prevFighter]     = temp;

        //Update UI
        abilityUIMap[prevFighter].updateStatus();

        selectedFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[selectedFighter]);
        prevFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[prevFighter]);

        selectedFighter.GetComponent <SpriteRenderer>().enabled = true;   //Disable character back
        selectedFighter.GetComponent <Collider2D>().enabled     = true;
        canMove = true;
    }
示例#3
0
 private void Start()
 {
     diving      = false;
     coll        = GetComponent <BoxCollider>();
     subInstance = submarineMovement.instance;
     abilityUI   = UIManager.instance.abilityUI;
 }
示例#4
0
    public void AttachAbilities(Ability[] abilities)
    {
        foreach (Ability ability in abilities)
        {
            // Sometimes ability is null
            if (!ability || !ability.ui)
            {
                continue;
            }
            AbilityUI ui = ability.ui;

            // Put it in a sane place in Unity hierarchy
            ui.transform.SetParent(abilitiesParent.transform);

            // Place in correct position in UI
            // The only way to tell if this ability has a UI is it if has an icon
            if (ability.icon)
            {
                ui.GetComponent <RectTransform>().anchoredPosition = abilityPositions_DEV[abilitiesPlaced].GetComponent <RectTransform>().anchoredPosition;
                abilitiesPlaced++;
            }
            // Apply player config
            ui.SetColor(playerConfig.color);
        }
    }
    //Private helper method for assistMoves: set selectedCharacter back to previous main character
    //  Pre: assist move is already in execution and partyIndex changed to the previous mainIndex
    //  Post: You are back to main character while a partner character is in execution
    private void goBackToMain(Vector3 originalPos)
    {
        PKMNEntity prevFighter = selectedFighter;   //Set previous fighter

        //Enables new fighter
        selectedFighter = transform.GetChild(partyIndex).GetComponent <PKMNEntity>();
        selectedFighter.transform.position = originalPos;
        selectedFighter.GetComponent <SpriteRenderer>().enabled = true;
        selectedFighter.GetComponent <Collider2D>().enabled     = true;

        //Switch UI elements
        secMoveIndex = 0;
        mainSwapper.switchAbilities(secMoveIndex);
        swapUIBars(selectedFighter, prevFighter);
        abilityUIMap[selectedFighter].swapIcons(abilityUIMap[prevFighter]);

        //Switches fighter mappings
        AbilityUI temp = abilityUIMap[selectedFighter];

        abilityUIMap[selectedFighter] = abilityUIMap[prevFighter];
        abilityUIMap[prevFighter]     = temp;

        selectedFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[selectedFighter]);
        prevFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[prevFighter]);

        //Set Main Character variables to fighter
        animator = selectedFighter.GetComponent <Animator>();
        player   = selectedFighter.GetComponent <Transform>();
    }
    //Private helper method: swap UI elements between partners
    //  Pre: numPartners > 2. Main Character has already been swapped with a partner
    //  Post: the 2 partners have already been swapped. Statuses do not change
    private void swapPartnerUI()
    {
        List <PKMNEntity> partners = new List <PKMNEntity>();

        //Get all partners (Will always run 3 times)
        for (int i = 0; i < numPartners; i++)
        {
            if (i != partyIndex)
            {
                partners.Add(transform.GetChild(i).GetComponent <PKMNEntity>());
            }
        }

        //Swap UI Elements
        swapUIBars(partners[0], partners[1]);
        abilityUIMap[partners[0]].swapIcons(abilityUIMap[partners[1]]);

        //Update mappings
        AbilityUI temp = abilityUIMap[partners[0]];

        abilityUIMap[partners[0]] = abilityUIMap[partners[1]];
        abilityUIMap[partners[1]] = temp;

        partners[0].GetComponent <SwitchState>().setUpState(abilityUIMap[partners[0]]);
        partners[1].GetComponent <SwitchState>().setUpState(abilityUIMap[partners[1]]);
    }
    //Switches to the character
    //  Pre: fighterIndex must have been changed to a different value before hand
    IEnumerator rotateCharacters()
    {
        selectedFighter.GetComponent <SwitchState>().disableSwitch(true);    //Disable switch state on selectedFighter

        //Do rotation
        swapMainCharUI(false);

        if (numPartners > 2)
        {
            swapPartnerUI();
        }
        else if (numPartners == 2 && assistFighter != null)
        {
            int        index       = (partyIndex == 0) ? 1 : 0;
            PKMNEntity sidePartner = transform.GetChild(index).GetComponent <PKMNEntity>();

            //Swap UI Elements
            swapUIBars(assistFighter, sidePartner);
            abilityUIMap[assistFighter].swapIcons(abilityUIMap[sidePartner]);

            //Update mappings
            AbilityUI temp = abilityUIMap[assistFighter];
            abilityUIMap[assistFighter] = abilityUIMap[sidePartner];
            abilityUIMap[sidePartner]   = temp;

            assistFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[assistFighter]);
            sidePartner.GetComponent <SwitchState>().setUpState(abilityUIMap[sidePartner]);
        }

        //Update UI states
        foreach (KeyValuePair <PKMNEntity, AbilityUI> entry in abilityUIMap)
        {
            entry.Value.updateStatus();
        }

        //Do transition animation
        canMove = false;
        float animTimer = 0.0f;

        animator.SetBool("Charging", true);
        yield return(new WaitForSeconds(0.1f));

        animator.SetBool("Charging", false);
        animator.SetBool("FinishedCharge", true);

        while (!selectedFighter.isStunned() && animTimer < TRANSITION_TIME && !attacking())
        {
            yield return(new WaitForFixedUpdate());

            animTimer += Time.deltaTime;
            combat();
        }

        animator.SetBool("FinishedCharge", false);
        if (!selectedFighter.isStunned() && selectedFighter.isAlive())
        {
            canMove = true;
        }
    }
示例#8
0
        public void AttachAbilityUITo(GameObject gameObjectToAttachTo)
        {
            AbilityUI abilityUI = GetUIComponent(gameObjectToAttachTo);

            abilityUI.Ability = this;
            this.abilityUI    = abilityUI;
            this.abilityUI.GetStats();
        }
    void Start()
    {
        PlayerController player = PlayerController.instance;

        for (int i = 0; i < player.m_Abilities.Length; i++)
        {
            AbilityUI abilityUi = Instantiate(abilityIconPrefab, abilityIconSlot);
            player.m_Abilities[i].OnAbilityUse.AddListener((cooldown) => abilityUi.ShowCoolDown(cooldown));
            abilityUi.SetIcon(player.m_Abilities[i].icon);
        }
    }
示例#10
0
 // TODO: Initialize the UI
 public void Init(BeingController owner, bool hasUI)
 {
     this.owner = owner;
     if (hasUI)
     {
         // Instantiate AbilityUI Obj
         abilityUIPrefab = FindObjectOfType <GameController>().abilityUIPrefab;
         ui = Instantiate(abilityUIPrefab).GetComponent <AbilityUI>();
         ui.Init(icon);
         // ui = newAbilityUIObj
     }
 }
示例#11
0
    void Start()
    {
        cameraPlane = new Plane();

        offset          = EffectMaterial.GetFloat("_ScanWidth") + EffectMaterial.GetFloat("_ScanDistanceOffset");
        maxScanDistance = EffectMaterial.GetFloat("_MaxScanDistance") + EffectMaterial.GetFloat("_ScanDistanceOffset") + EffectMaterial.GetFloat("_ScanWidth");
        maxScanCooldown = maxScanDistance / scanSpeed;

        if (scanCooldownImage != null)
        {
            scanCooldownImage.fillAmount = 0;
        }

        abilityUI = UIManager.instance.abilityUI;
    }
示例#12
0
    //Private helper method that switches characters if a main character is dead but partners (within rotation) are alive
    private IEnumerator mainMemberDeathFreePartners()
    {
        PKMNEntity prevFighter = selectedFighter;

        partyIndex %= numPartners;                  //Change partyIndex
        selectedFighter.transform.parent = null;    //Detaches parent

        //Enable new partner the GameObject. If a GameObject shares a parent with other GameObjects and are on the same level (i.e. they share the same direct parent), these GameObjects are known as siblings. The sibling index shows where each GameObject sits in this sibling hierarchy.

        selectedFighter = transform.GetChild(partyIndex).GetComponent <PKMNEntity>();
        animator        = selectedFighter.GetComponent <Animator>();
        player          = selectedFighter.GetComponent <Transform>();
        player.position = transform.position;

        canMove = false;
        yield return(new WaitForSeconds(DEATH_WAIT));

        canMove = true;

        selectedFighter.GetComponent <SpriteRenderer>().enabled = true;
        selectedFighter.GetComponent <Collider2D>().enabled     = true;

        //Switch UI elements
        secMoveIndex = 0;
        mainSwapper.switchAbilities(secMoveIndex);
        swapUIBars(selectedFighter, prevFighter);
        abilityUIMap[selectedFighter].swapIcons(abilityUIMap[prevFighter]);

        //Switches fighter mappings
        AbilityUI temp = abilityUIMap[selectedFighter];

        abilityUIMap[selectedFighter] = abilityUIMap[prevFighter];
        abilityUIMap[prevFighter]     = temp;
        abilityUIMap[prevFighter].updateStatus();
        setIsolation(false);

        yield return(StartCoroutine(recoveryFrames()));
    }
示例#13
0
    //Private helper method that swaps the main character (selectedFighter) with a partner character
    //  Pre: new partyIndex does not correspond with current selectedFighter in child array
    //  Post: The UI for main character and a partner character is swapped
    private void swapMainCharUI(bool assist)
    {
        //Disables current SelectedFighter and stores prev fighter (if assist is false)
        if (!assist)
        {
            selectedFighter.GetComponent <SpriteRenderer>().enabled = false;
            selectedFighter.GetComponent <Collider2D>().enabled     = false;
        }

        PKMNEntity prevFighter = selectedFighter;

        //Enables new fighter
        selectedFighter = transform.GetChild(partyIndex).GetComponent <PKMNEntity>();
        selectedFighter.GetComponent <SpriteRenderer>().enabled = true;
        selectedFighter.GetComponent <Collider2D>().enabled     = true;

        //Switch UI elements
        secMoveIndex = 0;
        mainSwapper.switchAbilities(secMoveIndex);
        swapUIBars(selectedFighter, prevFighter);
        abilityUIMap[selectedFighter].swapIcons(abilityUIMap[prevFighter]);

        //Switches fighter mappings
        AbilityUI temp = abilityUIMap[selectedFighter];

        abilityUIMap[selectedFighter] = abilityUIMap[prevFighter];
        abilityUIMap[prevFighter]     = temp;

        selectedFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[selectedFighter]);
        prevFighter.GetComponent <SwitchState>().setUpState(abilityUIMap[prevFighter]);

        //Set Main Character variables to fighter
        animator        = selectedFighter.GetComponent <Animator>();
        player          = selectedFighter.GetComponent <Transform>();
        player.position = transform.position;
    }
示例#14
0
 public void SetUI(AbilityUI ui)
 {
     abilityUI = ui;
     abilityUI.Load(abilityData);
 }
 /// <summary>
 /// Function that will look for a local player abilityUI object and get a reference to it.
 /// 
 /// Since the ability controller starts before the main scene is initialised, we can only get references
 /// to main scene objects after the main scene has loaded. These methods are called to attach the 
 /// ability controller to the respective main scene objects.
 /// </summary>
 /// <returns>This ability controller, so that calls can be chained.</returns>
 public AbilityController AttachToAbilityUi()
 {
     abilityUi = GameObject.Find("Canvas").transform.Find("Abilities").gameObject.GetComponent<AbilityUI>();
     if (abilityUi == null)
     {
         Debug.LogError("AbilityController failed to attach to AbilityUi.");
         return this;
     }
     Debug.Log(player.Name + " AbilityController attached to AbilityUi.");
     return this;
 }
示例#16
0
 //Set up method to access UIState
 public void setUpState(AbilityUI state)
 {
     UIState = state;
 }
示例#17
0
 public void LinkAbilityUIToACar(AbilityUI abilityUI)
 {
     this.abilityUI = abilityUI;
 }