public void Initialize(Transform root, Vector3 localPosition)
 {
     visuals = Instantiate(root.GetComponentInChildren <AbstractPlayerVisuals>().gameObject).GetComponent <AbstractPlayerVisuals>();
     visuals.transform.SetParent(this.transform, false);
     visuals.transform.localPosition = Vector3.zero;
     this.transform.SetParent(root, false);
     this.transform.localPosition = localPosition;
 }
 public void Initialize(Transform root, Vector3 localPosition)
 {
     visuals = Instantiate(root.GetComponentInChildren<AbstractPlayerVisuals>().gameObject).GetComponent<AbstractPlayerVisuals>();
     visuals.transform.SetParent(this.transform, false);
     visuals.transform.localPosition = Vector3.zero;
     this.transform.SetParent(root, false);
     this.transform.localPosition = localPosition;
 }
    public void UpdateCharacterSprite(int ID)
    {
        CharacterSprite.enabled = true;
        spriteSource            = registration.context.charactersData[ID].character.visuals.GetComponent <AbstractPlayerVisuals>();
        UpdateCharacterVisuals(characterVisualsVector = registration.context.charactersData[ID].character.initialVisualsVector);

        Assert.IsNull(readyRoutine);
        readyRoutine = SelectCharacterVisuals();
        StartCoroutine(readyRoutine);

        Assert.IsNull(gameVisualsRoutine);
        gameVisualsRoutine = UpdateCharacterVisuals();
        StartCoroutine(gameVisualsRoutine);
    }
    public void Initialize(InputToAction mirrorTarget)
    {
        this.mirrorTarget = mirrorTarget;
        mirrorRigidbody = mirrorTarget.GetComponent<Rigidbody2D>();
        visuals = Instantiate(mirrorTarget.GetComponentInChildren<AbstractPlayerVisuals>().gameObject).GetComponent<AbstractPlayerVisuals>();
        visuals.transform.SetParent(this.transform, false);
        visuals.transform.localPosition = Vector3.zero;

        GetComponent<StatsReference>().referencedStat = mirrorTarget.GetComponent<Stats>();

        UpdateMirror();
        mirrorTarget.PostFixedUpdateDelegates.Add(UpdateMirror);
        if (reverseInputOnMirror)
            mirrorTarget.PreFixedUpdateDelegates.Add(ReverseInput);
    }
    public void Initialize(InputToAction mirrorTarget)
    {
        this.mirrorTarget = mirrorTarget;
        mirrorRigidbody   = mirrorTarget.GetComponent <Rigidbody2D>();
        visuals           = Instantiate(mirrorTarget.GetComponentInChildren <AbstractPlayerVisuals>().gameObject).GetComponent <AbstractPlayerVisuals>();
        visuals.transform.SetParent(this.transform, false);
        visuals.transform.localPosition = Vector3.zero;

        GetComponent <StatsReference>().referencedStat = mirrorTarget.GetComponent <Stats>();

        UpdateMirror();
        mirrorTarget.PostFixedUpdateDelegates.Add(UpdateMirror);
        if (reverseInputOnMirror)
        {
            mirrorTarget.PreFixedUpdateDelegates.Add(ReverseInput);
        }
    }
    public void Init(int numGoals, int maxNumGoals, AbstractPlayerVisuals player)
    {
        this.numGoals = numGoals;
        this.maxNumGoals = maxNumGoals;
        this.player = player;
        playerContainer.sprite = player.selectionSprite();
        playerContainer.material = player.material;

        numGoalsText.text = numGoals.ToString();

        Callback.FireForUpdate(() => //Fire after the aspect ratio component has been initialized
        {
            transform.parent.GetComponent<LayoutElement>().preferredWidth = (transform as RectTransform).rect.width;

            LayoutElement barGraph = GetComponentInChildren<LayoutElement>();
            barGraph.flexibleHeight = 0;
            float targetHeight = ((float)numGoals / (float)maxNumGoals) * (barGraph.transform as RectTransform).rect.height;
            Callback.DoLerp((float l) => barGraph.preferredHeight = targetHeight * l * (3 + l * (-3 + l)), 1, this);
        }, this);
    }
Exemple #7
0
    public void Init(int numGoals, int maxNumGoals, AbstractPlayerVisuals player)
    {
        this.numGoals            = numGoals;
        this.maxNumGoals         = maxNumGoals;
        this.player              = player;
        playerContainer.sprite   = player.selectionSprite();
        playerContainer.material = player.material;

        numGoalsText.text = numGoals.ToString();

        Callback.FireForUpdate(() => //Fire after the aspect ratio component has been initialized
        {
            transform.parent.GetComponent <LayoutElement>().preferredWidth = (transform as RectTransform).rect.width;

            LayoutElement barGraph  = GetComponentInChildren <LayoutElement>();
            barGraph.flexibleHeight = 0;
            float targetHeight      = ((float)numGoals / (float)maxNumGoals) * (barGraph.transform as RectTransform).rect.height;
            Callback.DoLerp((float l) => barGraph.preferredHeight = targetHeight * l * (3 + l * (-3 + l)), 1, this);
        }, this);
    }
    public void UpdateCharacterSprite(int ID)
    {
        CharacterSprite.enabled = true;
        spriteSource = registration.context.charactersData[ID].character.visuals.GetComponent<AbstractPlayerVisuals>();
        UpdateCharacterVisuals(characterVisualsVector = registration.context.charactersData[ID].character.initialVisualsVector);

        Assert.IsNull(readyRoutine);
        readyRoutine = SelectCharacterVisuals();
        StartCoroutine(readyRoutine);

        Assert.IsNull(gameVisualsRoutine);
        gameVisualsRoutine = UpdateCharacterVisuals();
        StartCoroutine(gameVisualsRoutine);
    }