Пример #1
0
    //// Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            _testWeapon.AddWeaponPiece(_testNozzle);
            Destroy(_testNozzle.gameObject);
            _testNozzle = null;
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            _testWeapon.AddWeaponPiece(_testResonator);
            Destroy(_testResonator.gameObject);
            _testResonator = null;
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            _testWeapon.AddWeaponPiece(_testTrigger1);
            Destroy(_testTrigger1.gameObject);
            _testTrigger1 = null;
        }

        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            _testWeapon.AddWeaponPiece(_testTrigger2);
            Destroy(_testTrigger2.gameObject);
            _testTrigger2 = null;
        }
    }
Пример #2
0
 public void AddWeaponPiece(WeaponPiece piece)
 {
     if (piece.Type == WeaponPiece.WeaponPieceType.Resonator)
         _canFire |= EssentialPieces.Resonator;
     else if (piece.Type == WeaponPiece.WeaponPieceType.Nozzle)
         _canFire |= EssentialPieces.Nozzle;
     else if (piece.Type == WeaponPiece.WeaponPieceType.Trigger)
         _canFire |= EssentialPieces.Trigger;
 }
Пример #3
0
    void FirstPiece()
    {
        int pieceIndex = seed.Next(weaponGenSettings.handles.Count);

        GameObject  newObject = Instantiate(weaponGenSettings.handles[pieceIndex], parent.transform);
        WeaponPiece pieceInfo = newObject.GetComponent <WeaponPiece>();

        weaponPieces.Add(pieceInfo);
        foreach (ConnectPoint connection in pieceInfo.connections)
        {
            openConnections.Enqueue(connection);
        }
    }
Пример #4
0
    void Awake()
    {
        // if projectile is being carried by the player (as opposed to an enemy,)
        // animate the weapon while player is walking, jumping, etc
        if (transform.parent != null)
        {
            if (transform.parent.name == "Inventory")
            {
                // set weapon components on initialization
                upper  = transform.FindChild("Upper").gameObject.GetComponent <WeaponPiece>();
                center = transform.FindChild("Center").gameObject.GetComponent <WeaponPiece>();
                lower  = transform.FindChild("Lower").gameObject.GetComponent <WeaponPiece>();

                // set weapon colors here
                upper.spriteRenderer.material.SetColor("_Color", M.HexToColor(upperColor));
                center.spriteRenderer.material.SetColor("_Color", M.HexToColor(centerColor));
                lower.spriteRenderer.material.SetColor("_Color", M.HexToColor(lowerColor));
            }
        }
    }
Пример #5
0
    //Remove parts which do not allow for a connection of type prevConnection
    void FilterParts(ref List <GameObject> parts, ref List <ConnectPoint> acceptableConnections)
    {
        int i = parts.Count;

        while (i > 0)
        {
            --i;
            WeaponPiece         info   = parts[i].GetComponent <WeaponPiece>();
            List <ConnectPoint> points = info.connections;

            if (points.Count > 0)
            {
                foreach (ConnectPoint point in points)
                {
                    point.piece = info;
                    acceptableConnections.Add(point);
                }
            }
            else
            {
                parts.RemoveAt(i);
            }
        }
    }
Пример #6
0
    IEnumerator AddPiece(WeaponPiece.pieceType typeToAdd, Transform offset)
    {
        List <GameObject> acceptableParts = new List <GameObject>();

        switch (typeToAdd)
        {
        case WeaponPiece.pieceType.guard:
            acceptableParts.AddRange(new List <GameObject>(weaponGenSettings.guards));
            break;

        case WeaponPiece.pieceType.handle:
            acceptableParts.AddRange(new List <GameObject>(weaponGenSettings.handles));
            break;

        case WeaponPiece.pieceType.head:
            acceptableParts.AddRange(new List <GameObject>(weaponGenSettings.heads));
            break;

        case WeaponPiece.pieceType.pommel:
            acceptableParts.AddRange(new List <GameObject>(weaponGenSettings.pommels));
            break;

        case WeaponPiece.pieceType.shaft:
            acceptableParts.AddRange(new List <GameObject>(weaponGenSettings.shafts));
            break;

        default:
            Debug.Log("Weapon Generation Failed!");
            yield break;
        }
        //this guy should solve 90% of the remaining problems
        List <ConnectPoint> acceptableConnections = new List <ConnectPoint>();

        FilterParts(ref acceptableParts, ref acceptableConnections);

        if (acceptableConnections.Count == 0)
        {
            Debug.Log("Absolutely nothing works");
            yield break;
            //try a different part to add here
        }
        else
        {
            int pieceIndex = seed.Next(acceptableConnections.Count);
            //have to invert shit as usual
            Quaternion rot = Quaternion.Euler(180, 0, 0) * offset.rotation * acceptableConnections[pieceIndex].transform.rotation;
            Vector3    pos = offset.position - rot * (acceptableConnections[pieceIndex].transform.position);

            GameObject  newObject = Instantiate(acceptableConnections[pieceIndex].piece.prefab, pos, rot, parent.transform);
            WeaponPiece pieceInfo = newObject.GetComponent <WeaponPiece>();
            weaponPieces.Add(pieceInfo);
            foreach (ConnectPoint connection in pieceInfo.connections)
            {
                if (!(connection.transform.name == acceptableConnections[pieceIndex].transform.name))
                {
                    openConnections.Enqueue(connection);
                }
            }
        }
        yield return(null);
    }
Пример #7
0
    void Awake()
    {
        // if projectile is being carried by the player (as opposed to an enemy,)
        // animate the weapon while player is walking, jumping, etc
        if (transform.parent != null)
        {
            if (transform.parent.name == "Inventory")
            {
                // set weapon components on initialization
                upper  = transform.FindChild("Upper").gameObject.GetComponent<WeaponPiece>();
                center = transform.FindChild("Center").gameObject.GetComponent<WeaponPiece>();
                lower  = transform.FindChild("Lower").gameObject.GetComponent<WeaponPiece>();

                // set weapon colors here
               upper.spriteRenderer.material.SetColor("_Color", MLib.HexToColor(upperColor));
               center.spriteRenderer.material.SetColor("_Color", MLib.HexToColor(centerColor));
               lower.spriteRenderer.material.SetColor("_Color", MLib.HexToColor(lowerColor));
            }
        }
    }