コード例 #1
0
    /// <summary>
    /// Shows the swap rotate effect on the given GameObject
    /// 2020-12-18: copied from showLightningStatic()
    /// </summary>
    /// <param name="pos"></param>
    public void showSwapRotate(GameObject go, bool flip = false)
    {
        //Clean null values from list
        //(in case an object takes the effect with it when it unloads)
        swapRotateList.RemoveAll(tsu => tsu == null);
        //Check to make sure there isn't already an effect on it
        if (isEffectOnObject(swapRotateList, go))
        {
            return;
        }
        //Process effect
        SpriteRenderer sr = getAvailableEffect(
            swapRotateList,
            swapRotatePrefab
            );

        parentSpriteRendererToObject(sr, go);
        Vector3 scale = sr.transform.localScale;

        scale.x = Mathf.Abs(scale.x) * ((flip) ? -1 : 1);
        sr.transform.localScale = scale;
        SimpleRotation rot = sr.GetComponent <SimpleRotation>();

        rot.turnSpeed = Mathf.Abs(rot.turnSpeed) * ((flip) ? 1 : -1);
        sr.GetComponent <Fader>().enabled = true;
        sr.enabled = true;
    }
コード例 #2
0
    public virtual void StartState()
    {
        // Attach collisions
        stateMachine.colliderEvents.OnCollisionEnter_UE.AddListener(OnCollisionEnter_UE);

        GameObject model =
            Object.Instantiate(stateMachine.mapManager.GetStockTypePrefab(stateMachine.currentWantedProduct),
                               stateMachine.infoHalo,
                               true);

        // Remove physics
        Rigidbody rigidbody = model.GetComponent <Rigidbody>();

        rigidbody.isKinematic = true;

        // Move model to info halo position
        model.transform.position = stateMachine.infoHalo.position;

        // Disable all scripts on model
        MonoBehaviour[] scripts = model.GetComponents <MonoBehaviour>();
        foreach (MonoBehaviour script in scripts)
        {
            script.enabled = false;
        }

        // Add rotation script
        SimpleRotation rotationScript = model.AddComponent <SimpleRotation>();

        rotationScript.RotationDirection = rotationDirection;
        rotationScript.RotationSpeed     = rotationSpeed;

        // Keep reference of model
        spinItem = model;

        // Reset patience timer
        patienceTimer = stateMachine.stockPatience;
    }
コード例 #3
0
ファイル: SimpleRotation.cs プロジェクト: amatt1552/Riddel
 private void Start()
 {
     GC = GetComponent <SimpleRotation>();
 }