当前位置: 首页>>代码示例>>C#>>正文


C# Ship.GetComponent方法代码示例

本文整理汇总了C#中Ship.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Ship.GetComponent方法的具体用法?C# Ship.GetComponent怎么用?C# Ship.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ship的用法示例。


在下文中一共展示了Ship.GetComponent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Assign

    public void Assign(Ship ship, Color labelColor)
    {
        this.ship = ship;
        hitpoints = ship.GetComponent<Hitpoints>();
        wingmanCaptain = ship.GetComponent<WingmanCaptain>();

        nameLabel.color = labelColor;
        foreach (var selectionImage in selectionOverlay.GetComponentsInChildren<Image>())
        {
            selectionImage.color = labelColor;
        }

        Update();
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:14,代码来源:FleetListItem.cs

示例2: DamageMessage

	public DamageMessage (float dmg, Vector3 dir, float dmgFrce, Weapon.DamageBias bs, Weapon.WeaponType tp, Ship own)
	{
		damage = dmg;
		damageDirection = dir;
		damageForce = dmgFrce;
		bias = bs;
		type = tp;
		
		if (own != null)
			owner = own.gameObject;
		else
			return;
		
		hasShip = true;
		try
		{
			viewID = own.GetComponent<PhotonView>().viewID;
		}
		catch
		{
			Debug.Log(owner.name  + " does not have a photon View ID");
		}
		
		if (own is AiShip)
			player = false;
		else
			player = true;
	}
开发者ID:KenReaGameDev,项目名称:Apparent-Horizon,代码行数:28,代码来源:DamageMessage.cs

示例3: generateDisplay

    private void generateDisplay(Ship ship)
    {
        Shipyard constructionManager = ship.GetComponent<Shipyard>();
        if (null == constructionManager)
        {
            hide();
            return;
        }

        // clear the displayed buttons
        foreach (KeyValuePair<Shipyard.ShipCost, GameObject> button in _buttons) {
            Destroy(button.Value);
        }

        show();

        _buttons = new Dictionary<Shipyard.ShipCost, GameObject>();
        foreach (Shipyard.ShipCost option in constructionManager.BuildableShips)
        {
            GameObject button = Instantiate<GameObject>(ButtonPrefab);
            _buttons[option] = button;
            button.GetComponentInChildren<Text>().text = option.Message;
            button.transform.SetParent(gameObject.transform, false);

            // gotta declare a new ShipCost inside each loop iteration since C# closures are lexical
            // fuckin gets me every time
            Shipyard.ShipCost lexicallyEnclosedShip = option;
            button.GetComponent<Button>().onClick.AddListener(() => { constructionManager.tryEnqueueShip(lexicallyEnclosedShip); });
        }
    }
开发者ID:knexer,项目名称:VNReduxMiningPrototype,代码行数:30,代码来源:ConstructionOptionsDisplay.cs

示例4: generateDisplay

    private void generateDisplay(Ship ship)
    {
        _selectedShip = ship;
        ResourceTankAggregator tanks = ship.GetComponent<ResourceTankAggregator>();
        if (null == tanks)
        {
            hide();
            return;
        }

        // clear the display
        for (int i = 0; i < gameObject.transform.childCount; i++)
        {
            Destroy(gameObject.transform.GetChild(i).gameObject);
        }

        show();

        _resourceDisplays = new Dictionary<Resource, Text>();
        foreach (Resource resource in tanks.StoreableResources())
        {
            GameObject textObject = Instantiate(TextPrefab);
            textObject.transform.SetParent(gameObject.transform, false);
            _resourceDisplays[resource] = textObject.GetComponent<Text>();
        }

        updateText();
    }
开发者ID:knexer,项目名称:VNReduxMiningPrototype,代码行数:28,代码来源:ResourceDisplay.cs

示例5: SelectShip

    public void SelectShip(Ship shipSelected)
    {
        ship = shipSelected;
        ship.GetComponent<AIShipController>().enabled = false;
        ship.shipControllerSendDestroyed += OnShipDestroyed;
        ship.damageTaken += DamageTaken;

        _shipCamera.gameObject.SetActive(true);
        _shipCamera.transform.position = ship.cameraFollowLocation.transform.position;
        _shipCamera.transform.rotation = ship.transform.rotation;
        _shipCamera.transform.parent = ship.transform;
        _shipCamera.followTransform = ship.cameraFollowLocation.transform;

        if (ship.Weapons.Count > 0)
        {
            selectedWeapon = ship.Weapons[0];
        }

        foreach (Weapon weapon in ship.Weapons)
        {
            GameObject crosshair = (GameObject)Instantiate(crosshairPrefab);
            crosshair.name = weapon.name + " Crosshair";
            crosshair.transform.parent = dynamicGUIPanel.transform;
            crosshair.transform.localPosition = new Vector3(0, 1, 0);
            crosshair.transform.localScale = crosshairPrefab.transform.localScale;
            crosshairs.Add(crosshair);
        }

        if (ship.TurretController != null)
        {
            ship.TurretController.TakeControl();
        }
    }
开发者ID:sean-h,项目名称:spacegame,代码行数:33,代码来源:ShipController.cs

示例6: Awake

    void Awake()
    {
        _playerShip = GameObject.FindWithTag("PlayerShip").GetComponent<Ship>();
        _playerShipMovementBehavior = _playerShip.GetComponent<MovementBehavior>();

        var init = CooldownManager.Instance;
    }
开发者ID:RolexOsmiy,项目名称:Prisoners-of-Taal,代码行数:7,代码来源:StaticValues.cs

示例7: CreateFromShip

    public static Torpedo CreateFromShip(Ship ship, Ship owner)
    {
        var torpedo = ship.gameObject.AddComponent<Torpedo>();
        torpedo.torpedoShip = ship;
        torpedo.owner = owner;
        ship.Target = owner.Target;

        Physics.IgnoreCollision(ship.GetComponent<Collider>(), owner.GetComponent<Collider>());

        return torpedo;
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:11,代码来源:Torpedo.cs

示例8: AddToShip

    public static TrafficShip AddToShip(Ship ship)
    {
        var ai = ship.GetComponent<AITaskFollower>();
        if (!ai)
        {
            ai = AITaskFollower.AddToShip(ship);
        }

        var trafficShip = ship.gameObject.AddComponent<TrafficShip>();
        trafficShip.Start();

        return trafficShip;
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:13,代码来源:TrafficShip.cs

示例9: Activate

    public override void Activate(Ship activator, int slot)
	{
        if (Cooldown > 0)
        {
            return;
        }

        var hardpoint = activator.GetHardpointAt(slot);
        var module = activator.ModuleLoadout.GetSlot(slot);

        var aimingAt = module.Aim;
        if (hardpoint.CanAimAt(aimingAt))
        {
            var firedTransform = hardpoint ? hardpoint.transform : activator.transform;

            var aimRot = Quaternion.LookRotation((module.Aim - firedTransform.position).normalized);

            var bulletInstance = (Bullet)Instantiate(bulletType, firedTransform.position, aimRot);

            bulletInstance.owner = activator;
            var randomDamage = UnityEngine.Random.Range(minDamage, maxDamage);
            bulletInstance.damage = activator.ApplyDamageModifier(randomDamage);

            if (activator.GetComponent<Rigidbody>())
            {
                bulletInstance.baseVelocity = activator.GetComponent<Rigidbody>().velocity;
            }

            if (muzzleFlashType)
            {
                var flash = (Transform)Instantiate(muzzleFlashType, firedTransform.position, firedTransform.rotation);
                flash.SetParent(firedTransform, true);
            }

            Cooldown = fireRate;
        }        
	}
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:37,代码来源:GunBehaviour.cs

示例10: ShipInfo

        public ShipInfo(Ship fromShip, CharacterInfo captain, int transientId) : this()
        {
            TransientID = transientId;

            var rb = fromShip.GetComponent<Rigidbody>();

            name = fromShip.name;

            position = new SerializedVector3(rb.position);
            rotation = new SerializedQuaternion(rb.rotation);
            linearVelocity = new SerializedVector3(rb.velocity);
            angularVelocity = new SerializedVector3(rb.angularVelocity);

            targetable = fromShip.GetComponent<Targetable>();

            shipType = fromShip.ShipType.name;

            abilityCooldowns = fromShip.Abilities.Select(a => a.Cooldown).ToList();

            equippedModules = fromShip.ModuleLoadout
                .Select(m => m != null? new ModuleInfo(m) : null)
                .ToList();

            var hp = fromShip.GetComponent<Hitpoints>();
            if (hp)
            {
                armor = hp.GetArmor();
                shield = hp.GetShield();
            }
            else
            {
                armor = -1;
                shield = -1;
            }

            Captain = captain;
        }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:37,代码来源:ShipInfo.cs

示例11: PredictTarget

    public override Vector3? PredictTarget(Ship activator, int slot, Targetable target)
    {
        Vector3 speedDiff;
        var targetBody = target.GetComponent<Rigidbody>();
        var activatorBody = activator.GetComponent<Rigidbody>();

        if (bulletType.applyBaseVelocity)
        {
            if (targetBody && activatorBody)
            {
                speedDiff = targetBody.velocity - activatorBody.velocity;
            }
            else if (activatorBody)
            {
                speedDiff = -activatorBody.velocity;
            }
            else
            {
                speedDiff = Vector3.zero;
            }
        }
        else
        {
            if (targetBody)
            {
                speedDiff = targetBody.velocity;
            }
            else
            {
                speedDiff = Vector3.zero;
            }
        }

        float distToTarget = (target.transform.position - activator.transform.position).magnitude;
        float timeToHit = distToTarget / bulletType.velocity;

        speedDiff *= timeToHit;

        var targetPos = target.transform.position;
        targetPos += speedDiff;

        return targetPos;
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:43,代码来源:GunBehaviour.cs

示例12: SetTarget

	/// <summary>
	/// Sets the target ship which the camera should follow. This is always the active player in the game
	/// </summary>
	/// <param name="target">The target ship which should be followed</param>
	public void SetTarget( Ship target )
	{
		m_Target = target;

		//The DecalIcon of a ship is the small diamond that indicates where the ship is. But we don't want to display it for the active player
		Destroy( m_Target.GetComponent<DecalIcon>() );
	}
开发者ID:EvilAbyss,项目名称:Wulfram,代码行数:11,代码来源:CameraShipFollow.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        if (owner == null) {
            return;
        }

        GameObject shipObject = (GameObject)Instantiate (owner.GetComponent<Ship> ().gameObject);
        ship = shipObject.GetComponent<Ship> ();

        Ship ownerShip = owner.GetComponent<Ship> ();

        Vector3 pos = ownerShip.transform.position;
        float angle = ownerShip.transform.eulerAngles.z;

        ship.transform.position = new Vector3 (
            pos.x - Mathf.Sin(angle / Mathf.Rad2Deg) * -2,
            pos.y + Mathf.Cos(angle / Mathf.Rad2Deg) * -2,
            0
        );

        Owner info = owner.GetComponent<Owner> ();
        ownerNum = info.getOwnerNum ();
        info.emptyDecoy ();
        if (info) {
            this.name = "decoy" + ownerNum;
        } else {
            this.name = "decoy";
        }

        Owner[] owners = Object.FindObjectsOfType<Owner> ();
        for (int i = 0; i < owners.Length; i++) {
            if (owners [i].getOwnerNum () == ownerNum) {
                owners [i].addDecoy ();
            }
        }

        Owner decoyOwner = shipObject.GetComponent<Owner> ();
        decoyOwner.setOwnerNum (info.getOwnerNum ());

        ship.transform.parent = this.transform;

        int num = ship.transform.childCount;
        for (int i = 0; i < num; i++) {

            GameObject child = ship.transform.GetChild (i).gameObject;

            if (child.tag == "Pointer" || child.tag == "Shield") {
                Destroy (child);
            }
        }

        Damageable dm = ship.GetComponent<Damageable> ();
        dm.setArmor (decoyArmor);

        ship.shipController = ShipController.decoy;

        NetworkServer.Spawn (shipObject);

        turnCount = 0;
    }
开发者ID:MilesAway1980,项目名称:Battle-Action,代码行数:61,代码来源:Decoy.cs


注:本文中的Ship.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。