Пример #1
0
    /**
     * <summary>
     * Initialize parts
     * </summary>
     *
     * <returns>
     * void
     * </returns>
     */
    protected void InitializeParts()
    {
        TankUnitWeaponPart weapon    = this.top.GetComponent <TankUnitWeaponPart>();
        TankUnitBodyPart   bodyFrame = this.body.GetComponent <TankUnitBodyPart>();

        List <TankUnitPart> newParts = new List <TankUnitPart>();

        newParts.Add(weapon);
        newParts.Add(bodyFrame);

        this.SetTankParts(newParts);
    }
Пример #2
0
    /**
     * <summary>
     * Adjust weapon position when switching new weapons or new frames.
     * </summary>
     *
     * <returns>
     * void
     * </returns>
     */
    public void AdjustWeaponPosition()
    {
        TankUnitWeaponPart tankWeapon = this.GetWeapon().GetComponent <TankUnitWeaponPart>();
        TankUnitBodyPart   tankBody   = this.GetBody().GetComponent <TankUnitBodyPart>();

        Vector3 newLocalPosition = Vector3.zero;

        /**
         * Medium single barrel and medium frame OR
         * Medium double barrel and medium frame
         */
        if (
            tankWeapon.GetID() == TankUnitPartID.Weapon.MediumSingleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.MediumFrame ||
            tankWeapon.GetID() == TankUnitPartID.Weapon.MediumDoubleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.MediumFrame
            )
        {
            newLocalPosition = new Vector3(0f, 0.4f, -0.25f);
        }

        /**
         * Heavy single barrel and medium frame OR
         * Heavy double barrel and medium frame
         */
        else if (
            tankWeapon.GetID() == TankUnitPartID.Weapon.HeavySingleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.MediumFrame ||
            tankWeapon.GetID() == TankUnitPartID.Weapon.HeavyDoubleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.MediumFrame
            )
        {
            newLocalPosition = new Vector3(0f, 0.45f, -0.37f);
        }

        /**
         * Medium single barrel and light frame OR
         * Medium double barrel and light frame
         */
        else if (
            tankWeapon.GetID() == TankUnitPartID.Weapon.MediumSingleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.LightFrame ||
            tankWeapon.GetID() == TankUnitPartID.Weapon.MediumDoubleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.LightFrame
            )
        {
            newLocalPosition = new Vector3(0f, 0.485f, -0.1f);
        }

        /**
         * Heavy single barrel and light frame OR
         * Heavy double barrel and light frame
         */
        else if (
            tankWeapon.GetID() == TankUnitPartID.Weapon.HeavySingleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.LightFrame ||
            tankWeapon.GetID() == TankUnitPartID.Weapon.HeavyDoubleBarrel &&
            tankBody.GetID() == TankUnitPartID.Body.LightFrame
            )
        {
            newLocalPosition = new Vector3(0f, 0.55f, -0.405f);
        }

        this.top.transform.localPosition = newLocalPosition;
    }