示例#1
0
    void OnEnable()
    {
        currentMonString = "";

        int currentMonID = MonAgent.GetCurrentMonID();

        currentMon = MonAgent.MonFromID(currentMonID);

        if (currentMonID != -1)
        {
            currentMonString = currentMon.ToString();
        }


        newMonString = "";

        int newMonID = MonAgent.GetLastFoundMonID();

        newMon = MonAgent.MonFromID(newMonID);

        if (newMonID != -1)
        {
            newMonString = newMon.ToString();
        }

        vsString = "VS";

        StartCoroutine("DoBattle");
    }
示例#2
0
    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren <Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren <Collider>(true);

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

        MarkerBehaviour markerBehaviour = GetComponent <MarkerBehaviour>();

        if (markerBehaviour)
        {
            MonAgent.SetLastFoundMonID(markerBehaviour.Marker.MarkerID);
            StateAgent.ChangeState(StateAgent.State.Playing);
        }
    }
示例#3
0
    void Awake()
    {
        if (mInstance != null)
        {
            Debug.LogError(string.Format("Only one instance of MonAgent allowed! Destroying:" + gameObject.name + ", Other:" + mInstance.gameObject.name));
            Destroy(gameObject);
            return;
        }

        mInstance = this;
    }
示例#4
0
    void OnEnable()
    {
        content = "Find a friend!";

        int monID = MonAgent.GetCurrentMonID();

        if (monID != -1)
        {
            content = MonAgent.MonFromID(monID).ToString();
        }

        VisualEncryptorAgent.DisplaySprite(monID);
    }
示例#5
0
    void Start()
    {
        if (MonAgent.GetMonPrefab() == null)
        {
            enabled = false;
            return;
        }

        currentChannelPositions = new List <int>();
        segments             = new List <GameObject>();
        shotsFired           = new List <GameObject>();
        shotChannels         = new List <int>();
        damagingShotChannels = new List <int>();

        Reset();
    }
示例#6
0
    public void Reset()
    {
        int randomValue = Mathf.FloorToInt(Random.value * 3f);

        switch (randomValue)
        {
        case 0: numSegments = 1; shotSpeedPercent = 2f; break;

        case 1: numSegments = 2; shotSpeedPercent = 1f; break;

        case 2: numSegments = 4; shotSpeedPercent = 0.5f; break;
        }

        currentChannelPositions.Clear();

        for (int i = 0; i < segments.Count; i++)
        {
            Destroy(segments[i]);
        }

        segments.Clear();

        StopCoroutine("RunShotsFired");
        DestroyShotsFired();

        for (int i = 0; i < numSegments; i++)
        {
            if (numSegments == 4 && i > 1)
            {
                currentChannelPositions.Add((BoardAgent.NumChannels / 2 + (i - 3) * (isDefender ? 1 : -1)));
                segments.Add(Instantiate(MonAgent.GetMonPrefab(), BoardAgent.ChannelPositionToScreenPosition(currentChannelPositions[i], isDefender) + Vector3.up * BoardAgent.ChannelWidth * (isDefender ? 1f : -1f), rotation) as GameObject);
            }
            else
            {
                currentChannelPositions.Add((BoardAgent.NumChannels / 2 + (i - 1) * (isDefender ? 1 : -1)));
                segments.Add(Instantiate(MonAgent.GetMonPrefab(), BoardAgent.ChannelPositionToScreenPosition(currentChannelPositions[i], isDefender), rotation) as GameObject);
            }

            segments[i].transform.parent     = transform;
            segments[i].transform.localScale = Vector3.one * BoardAgent.ChannelWidth * 0.75f;
        }
    }
示例#7
0
    public void Shoot()
    {
        bool shouldStartCoroutine = (shotsFired.Count == 0);

        for (int i = 0; i < segments.Count; i++)
        {
            int newShotChannel = currentChannelPositions[i];
            shotChannels.Add(newShotChannel);

            GameObject newShot = Instantiate(MonAgent.GetShotPrefab(), segments[i].transform.position, rotation) as GameObject;
            newShot.transform.localScale = Vector3.one * BoardAgent.ChannelWidth * 0.25f;

            shotsFired.Add(newShot);
        }

        if (shouldStartCoroutine)
        {
            StartCoroutine("RunShotsFired");
        }
    }
示例#8
0
    private IEnumerator DoBattle()
    {
        yield return(new WaitForSeconds(3f));

        if (currentMon.currentTypeType == MonAgent.TypeType.Invalid)
        {
            currentMon = new MonAgent.Mon(newMon.currentTypeType, newMon.currentAttack1Type, newMon.currentAttack2Type);
        }
        else
        {
            int randomValue = Mathf.FloorToInt(Random.value * 3f);

            switch (randomValue)
            {
            case 0: currentMon = new MonAgent.Mon(MonAgent.GetComboTypeType(newMon.currentTypeType, currentMon.currentTypeType), currentMon.currentAttack1Type, currentMon.currentAttack2Type); break;

            case 1: currentMon = new MonAgent.Mon(currentMon.currentTypeType, newMon.currentAttack1Type, currentMon.currentAttack2Type); break;

            case 2: currentMon = new MonAgent.Mon(currentMon.currentTypeType, currentMon.currentAttack1Type, newMon.currentAttack2Type); break;
            }
        }

        currentMonString = currentMon.ToString();

        MonAgent.SetCurrentMonID(MonAgent.IDFromMon(currentMon));
        MonAgent.SetLastFoundMonID(-1);

        yield return(new WaitForSeconds(1f));

        newMonString = "";
        vsString     = "";

        yield return(new WaitForSeconds(3f));

        StateAgent.ChangeState(StateAgent.State.Showing);
    }
示例#9
0
    void Awake()
    {
        if( mInstance != null )
        {
            Debug.LogError( string.Format( "Only one instance of MonAgent allowed! Destroying:" + gameObject.name +", Other:" + mInstance.gameObject.name ) );
            Destroy( gameObject );
            return;
        }

        mInstance = this;
    }