Наследование: MonoBehaviour
Пример #1
0
    public void ReboundRaycast(RaycastHit2D preHit, float residueDistance, Vector2 incomingVector)
    {
        //获得反射向量
        Vector2 reflectVector = Vector2.Reflect(incomingVector, preHit.normal);
        Vector2 startPoint    = preHit.point - incomingVector.normalized * sr.size.y * 0.5f - reflectVector.normalized * sr.size.y * 0.5f + reflectVector.normalized * 0.0001f;

        RaycastHit2D hit = Physics2D.Raycast(startPoint, reflectVector, residueDistance, LayerMask.GetMask(maskLayer));


        float currDistance;

        if (hit.collider)
        {
            currDistance = hit.fraction * residueDistance;
        }
        else
        {
            currDistance = residueDistance;
        }

        Raycast    raycast     = Instantiate((GameObject)Resources.Load("Bullet/Raycast/Raycast")).GetComponent <Raycast>();
        Quaternion newRotation = Quaternion.FromToRotation(Vector2.right, reflectVector);

        raycast.ConfigRaycast(currDistance, fireWeapon, residueTimes - 1, startPoint, newRotation, maskLayer, raycastHoldTime);
        nextRaycast = raycast;
        float nextRaycastDistance = residueDistance - currDistance;

        if (nextRaycast.residueTimes > 0 && nextRaycastDistance > 0)
        {
            nextRaycast.ReboundRaycast(hit, nextRaycastDistance, reflectVector);
        }
    }
Пример #2
0
        public override void DoInteraction(Player player)
        {
            if (!(player.Inventory.CurrentItem is PhotoItem photo))
            {
                return;
            }

            var raycast = Raycast.RaycastInteractable(player.Camera.transform, out var hit);

            if (!raycast)
            {
                return;
            }

            player.DropCurrentItem();
            photo.Rigidbody.isKinematic = true;
            photo.Collider.isTrigger    = true;
            photo.transform.SetParent(transform);

            StartCoroutine(Animator.AnimateConcurrent(
                               new[]
            {
                Animator.MoveToWorld(photo.transform, hit.point, .7f, Easing.OutCubic),
                Animator.RotateToLocal(photo.transform, Quaternion.Euler(-90, -90, 0), .7f, Easing.OutCubic)
            }));
        }
Пример #3
0
        void InputInteract()
        {
            if (!controlsEnabled)
            {
                return;
            }

            if (Raycast.CastVoxel(currentWorld.WorldCamera.Position, currentWorld.WorldCamera.GetForward(), 5,
                                  out RayVoxelOut op))
            {
                int  x             = (int)Math.Floor(GetPositionInChunk().X);
                int  z             = (int)Math.Floor(GetPositionInChunk().Z);
                bool isPlayerAtPos = (int)op.PlacementPosition.X == x && (int)op.PlacementPosition.Z == z;
                if (currentWorld.TryGetChunkAtPosition((int)op.PlacementChunk.X, (int)op.PlacementChunk.Y, out Chunk chunk) &&
                    !isPlayerAtPos)
                {
                    var stack = inventory.GetItemStackByLocation(inventory.SelectedItemIndex, 0);
                    if (stack != null)
                    {
                        stack.Item.OnInteract(op.PlacementPosition, chunk);
                        inventory.RemoveItemFromStack(stack.Item, stack);
                        currentWorld.RequestChunkUpdate(chunk, true, (int)op.BlockPosition.X, (int)op.BlockPosition.Z);
                    }
                }
            }
        }
Пример #4
0
        public override void Update()
        {
            if (!hasHadInitialSet)
            {
                Position.Y = Chunk.HEIGHT;
                if (Raycast.CastVoxel(new Vector3(Position),
                                      new Vector3(0, -1, 0), Chunk.HEIGHT, out RayVoxelOut hit))
                {
                    var chunkWp = (hit.BlockPosition);
                    Position = chunkWp + new Vector3(0.5f, Chunk.HEIGHT, 0.5f);
                    Debug.Log("Hit block for y pos " + Position.Y);
                    rigidbody        = new Rigidbody(this, 70, new BoundingBox(-0.25f, 0.25f, 0, 2, -0.25f, 0.25f));
                    hasHadInitialSet = true;
                }
            }

            currentWorld.WorldCamera.Position = Position + new Vector3(0, 1.7f, 0);

            if (hasHadInitialSet)
            {
                HandleInput();

                var chunkPos = Position.ToChunkPosition();
                if (World.GetInstance().TryGetChunkAtPosition((int)chunkPos.X, (int)chunkPos.Z, out Chunk chunk))
                {
                    var block = Position.ToChunkSpaceFloored();
                    isInWater      = chunk.GetBlockID((int)block.X, (int)block.Y, (int)block.Z) == GameBlocks.WATER.ID;
                    rigidbody.Drag = isInWater ? UnderWaterDrag : 0;
                }
            }

            if (currentWorld.HasFinishedInitialLoading)
            {
                if (lastHungerLossTick + hungerLossTickRate <= Time.GameTime)
                {
                    hungerLossAmount = isSprinting ? 0.25f : 0.01f;

                    if (currentHunger > 0)
                    {
                        currentHunger -= hungerLossAmount;
                    }
                    else
                    {
                        currentHealth -= 0.0625f;
                        TakeDamage(0);
                    }
                    lastHungerLossTick = Time.GameTime;
                }

                if (lastHealthIncreaseTick + healthIncreaseTickRate <= Time.GameTime)
                {
                    if (currentHealth < MAX_HEALTH && currentHunger == MAX_HUNGER)
                    {
                        SetHealth((int)currentHealth + 1);
                    }

                    lastHealthIncreaseTick = Time.GameTime;
                }
            }
        }
    public override void Activate(CreatureStates Creature, Raycast Raycast, Good.Times.State State)
    {
        base.Activate (Creature, Raycast, State);
        if (State == State.BeginningOfTurn)
        {
            RecordHeight(Creature,Raycast);
        }

        if (State == State.Jump)
        {
            if (Raycast.SearchForCreature(Creature.Front,Creature.Storey) &&
                Raycast.SearchForHeight(Creature.Front,true) &&
                Creature.Jump >= Raycast.TargetMultipleCreature.Count)
            {
                float x = Raycast.TargetCreature.transform.position.x;
                float y = Raycast.TargetCreature.transform.position.y;
                float AddHeight = Raycast.TargetMultipleCreature.Select(h => h.Height).Sum();
                Move(Creature,x,y + AddHeight);
                Creature.Storey = Raycast.TargetMultipleCreature.OrderByDescending(s => s.Storey).ToList()[0].Storey + 1;
            }
        }

        if (State == State.EndOfTurn)
        {
            RecordHeight(Creature,Raycast);
            Fall(Creature, Raycast);
        }
    }
Пример #6
0
        protected virtual void Ray(float maxDistance, List <GameObject> objects, Vector3 direction)
        {
            closestObjectDistance = null;
            closestObject         = null;
            Raycast ray = new Raycast(Owner.GlobalPosition, direction, maxDistance);

            foreach (GameObject go in objects)
            {
                if (go == Owner)
                {
                    continue;
                }
                Collider col = go.GetComponent <Collider>();
                if (go.IsVisible && go.Name != "Level")
                {
                    float?distance = (col != null ? ray.Intersect(col.bound) : ray.Intersect(go.Bound));
                    if (distance != null)
                    {
                        if (closestObjectDistance == null || distance < closestObjectDistance)
                        {
                            closestObjectDistance = distance;
                            closestObject         = go;
                        }
                    }
                }
            }
        }
Пример #7
0
        private void UpdateFireBeam(Vector2 toTarget, float width)
        {
            Vector2 beam = Vectors2.FromDegAngle(beamAngle, beamLength);

            float angle = Vector2.SignedAngle(beam, toTarget);

            if (angle != 0)
            {
                System.Func <float, float, float> minMax = angle > 0 ?
#pragma warning disable IDE0004 //Unity needs this because Unity is a little bitch
                                                           (System.Func <float, float, float>)Mathf.Min :
                                                           (System.Func <float, float, float>)Mathf.Max;
#pragma warning restore IDE0004
                float change = minMax(angle, aimSpeed *
                                      Time.deltaTime * (angle / (Mathf.Abs(angle))));

                beamAngle += change;
            }

            if (Raycast.TryRaycast2d(Pupil.position, beam,
                                     out RaycastHit2D hit2d, SelfOrbiter.Owner.body.Collider,
                                     SelfOrbiter.Collider))
            {
                beam = hit2d.point;
                float length = ((Vector2)Pupil.position - beam).magnitude;
                if (beamLength > length)
                {
                    beamLength = length;
                }

                HitTarget(hit2d, width);
                //HitParticles(hit2d, width);
            }
Пример #8
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #9
0
 // Start is called before the first frame update
 void Start()
 {
     mt.text = Mercury_Value.ToString() + "°C";
     nt.text = Neptune_Value.ToString() + "°C";
     water   = GameObject.Find("Water");
     rc      = GameObject.Find("Main Camera").GetComponent <Raycast>();
 }
Пример #10
0
    private void Start()
    {
        string fileName = Path.Combine(Application.streamingAssetsPath, objFile);

        if (!File.Exists(fileName))
        {
            Debug.LogError("FILE COULD NOT BE FOUND!");
            return;
        }

        string objData = File.ReadAllText(fileName);
        int    objLen  = (int)(objData.Split('o').Length * 1.2f);

        debugMeshes = new List <Mesh>(objLen);
        gameWorld   = new world(objLen);
        MeshHelpers.CreateMeshesFromEpa(objData);
        Raycast.InitRaycastData(ref gameWorld);

        //Generate Ground plane.
        bounds ground = new bounds();

        ground.minPoints = new float3(-1000, -.1f, -1000);
        ground.maxPoints = new float3(1000, .1f, 1000);

        groundMesh = MeshHelpers.MakeCubeFromBounds(ground);
        groundMesh.RecalculateBounds();
        entity groundEntity = new entity();

        groundEntity.bounds.minPoints = groundMesh.bounds.min;
        groundEntity.bounds.maxPoints = groundMesh.bounds.max;
        groundEntity.name             = "Ground";
        GameWorld.AddEntity(ref gameWorld, ref groundEntity);
    }
Пример #11
0
 void Start()
 {
     myAnimator  = GetComponent <Animator>();
     myRigidBody = GetComponent <Rigidbody2D>();
     ray         = GetComponent <Raycast>();
     StartCoroutine(StartBounceAnimation());
 }
Пример #12
0
    public void SelectPhoto(GameObject photo)
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit) == true)
        {
            Renderer renderer = photo.transform.GetComponent <Renderer>();

            foreach (List <string> list in listPhotos)
            {
                if (list[0] == hit.transform.name.ToString())
                {
                    if (list.Contains(renderer.name) == false)
                    {
                        list.Add(renderer.name);

                        Raycast photoInstance = GameObject.Find(Raycast.GetPhotoZoom().transform.name).GetComponent <Raycast>();
                        photoInstance.CreateMarcadorPhoto(Raycast.GetPhotoZoom(), hit.transform.gameObject.GetComponent <Renderer>().material.color);

                        UpdateTextContainer(hit.transform.name.ToString());
                    }
                    break;
                }
            }

            /*colorContainer = transform.GetComponent<Renderer>().material.color;
             * Debug.Log("luego del while" + colorContainer);
             * StartCoroutine(MarcarContainer(hit.transform.gameObject));
             * Debug.Log("luego del while" + colorContainer);
             * hit.transform.GetComponent<Renderer>().material.color = colorContainer;*/
        }
    }
Пример #13
0
    private void Update()
    {
        Ray            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        float3         dir = ray.direction;
        float3         pos = ray.origin;
        raycast_result result;

        if (Input.GetKeyDown(KeyCode.Mouse1))
        {
            System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
            Raycast.RaycastJob(ref gameWorld, pos, dir, 1000, out result);
            sw.Stop();
            Debug.Log($"Raycast took {sw.ElapsedMilliseconds}ms and hit {result.hitPos.x}, {result.hitPos.y}, {result.hitPos.z}");
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            go.transform.localScale = new Vector3(.35f, .25f, .25f);
            go.transform.position   = result.hitPos;
            Debug.DrawLine(pos, result.hitPos, new Color32(122, 0, 122, 255), 10000);
        }

        float  boxDimWithPadding = (gameWorld.entityCount * .5f) + gameWorld.entityCount;
        Bounds b = new Bounds(new Vector3(boxDimWithPadding / 2, 0, boxDimWithPadding / 2), new Vector3(boxDimWithPadding, 100, boxDimWithPadding));

        //positionBuffer.SetData(positions);
        //material.SetBuffer("positionBuffer", positionBuffer);
        Graphics.DrawMeshInstancedIndirect(boxMesh, 0, material, b, argsBuffer);
    }
Пример #14
0
    public void Fire()
    {
        ShakeCameraAndRepel();
        shakeCameraStepTimer = 0.0f;

        Vector2      direction           = CalTargetDirection(firePoint.transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition), transform.position);
        RaycastHit2D hit                 = Physics2D.Raycast(firePoint.transform.position, direction, raycastDistance, LayerMask.GetMask(maskLayer));
        float        currRaycastDistance = 0;

        if (hit.collider)
        {
            currRaycastDistance = hit.fraction * raycastDistance;
        }
        else
        {
            currRaycastDistance = raycastDistance;
        }
        Raycast raycast = Instantiate((GameObject)Resources.Load("Bullet/Raycast/Raycast")).GetComponent <Raycast>();

        raycast.ConfigRaycast(currRaycastDistance, this, reboundTimes, firePoint.transform.position, weaponPoint.transform.rotation, maskLayer, raycastHoldTime);
        if (raycast.residueTimes > 0 && hit.collider)
        {
            raycast.ReboundRaycast(hit, (1 - hit.fraction) * raycastDistance, direction);
        }

        if (weaponType == EWeaponType.coutinue || weaponType == EWeaponType.storagePowerAndCoutinue)
        {
            raycast.transform.parent = weaponPoint.transform;
        }
        currRaycast = raycast;
    }
 protected void VanillaSlash(CreatureStates Creature,Raycast Raycast, Vector3 SlashDirection)
 {
     if (Raycast.SearchForCreature(SlashDirection, Creature.Storey))
     {
         Raycast.TargetCreature.Health -= Creature.Damage;
     }
 }
Пример #16
0
    void Start()
    {
        core = transform.GetChild(0).gameObject;
        ray  = GetComponent <Raycast>();

        Lob();
    }
Пример #17
0
 private void Awake()
 {
     raycast = new Raycast()
     {
         Origin = () => transform.position
     };
     detector = new GroundDetector(raycast, distance, 0f, distance);
 }
Пример #18
0
    void Awake()
    {
        _CameraMovementA = Camera.main.transform.parent.GetComponent <CameraMovement>();
        _CameraMovementB = Camera.main.GetComponent <CameraMovement>();
        _Raycast         = Camera.main.GetComponent <Raycast>();

        _InventoryUI = GameObject.FindGameObjectWithTag("InventoryHolder");
    }
 public override void Activate(CreatureStates Creature, Raycast Raycast, State State)
 {
     base.Activate (Creature, Raycast, State);
     if (State == State.Use)
     {
         VanillaSlash(Creature,Raycast,Creature.Front);
     }
 }
 public override void Activate(CreatureStates Creature, Raycast Raycast, State State)
 {
     base.Activate (Creature, Raycast, State);
     if (State == WhenToActivate)
     {
         Creature.Health+=Health;
     }
 }
Пример #21
0
    public override void OnPointerEnter(PointerEventData data)
    {
        //	Debug.Log ("OnPointerEnter called");
        //GameObject water = GameObject.FindGameObjectWithTag ("Water");
        Raycast rock = GetComponent <Raycast> ();

        rock.GetComponent <Raycast> ().RayCastEnter(2);
    }
Пример #22
0
 // Animation
 //public Animator anim;
 // Use this for initialization
 void Start()
 {
     cast = gameObject.GetComponent<Raycast> ();
     //anim = gameObject.GetComponent<Animator> ();
     acceleration = 0.67f;
     targetSpeed = 3.5f;
     brakeSpeed = 1.00f;
 }
 void DrawLine(Raycast RaycastGUI, float Length)
 {
     Vector3 Position = RaycastGUI.Position();
     float x = Length;
     float y = 0f;
     Handles.color = Color.red;
     Handles.DrawLine(Position,new Vector3(Position.x + x,Position.y + y,0f));
 }
Пример #24
0
 void DrawLine(Raycast RaycastEditor, float Length)
 {
     Vector2 Position = RaycastEditor.Position();
     float x = Length;
     float y = 0f;
     Handles.color = Color.red;
     Handles.DrawLine(Position,new Vector2(Position.x + x,Position.y + y));
 }
Пример #25
0
        /// <summary>
        /// Create a new ground detector with the specified raycast type, hover distance, ground detection buffer, and detection distance
        /// </summary>
        /// <param name="raycast"></param>
        /// <param name="hoverDistance"></param>
        /// <param name="groundDetectionBuffer"></param>
        /// <param name="detectionDistance"></param>
        public GroundDetector(Raycast raycast, float hoverDistance, float groundDetectionBuffer, float detectionDistance)
        {
            this.raycast = raycast;

            this.hoverDistance         = hoverDistance;
            this.groundDetectionBuffer = groundDetectionBuffer;
            this.detectionDistance     = detectionDistance;
        }
Пример #26
0
    /*
    public override void Attack_Status (System_Control.Phase Activate_On_What_Phase)
    {
        base.Attack_Status (Activate_On_What_Phase);
        if (Activate_On_What_Phase == Phase.Counter_Attack_Hit)
        {
            if (Activate_Once)
            {
                Activate_Once = false;
                //Creature_Attack.Hit_Me_Baby(Creature_Equipment);
            }
        }
    }*/
    public override void Activate(Creature_States Creature, Raycast Raycast, State State, Attack Attack)
    {
        base.Activate (Creature, Raycast, State, Attack);

        if (State == State.Counter_Attack_Hit)
        {

        }
    }
Пример #27
0
 void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     Instance = this;
     DontDestroyOnLoad(transform.gameObject);
 }
Пример #28
0
 // Start runs once
 void Start()
 {
     rate           = (int)RecordRate;
     debugkey       = interpretDebugKey(DebugViewButton);
     cam_gameobject = this.gameObject;
     debug_text_hud = cam_gameobject.AddComponent <debugText>();
     collectedData  = new POD();
     raycaster      = this.gameObject.AddComponent <Raycast>();
 }
Пример #29
0
 public static void ShrinkRaycast(Raycast raycast, byte[,] obstacles)
 {
     for (int i = 0; i < raycast.Count; i++)
     {
         if (obstacles[raycast[i].X, raycast[i].Y] == 255)
         {
             raycast.CutEnd(i);
         }
     }
 }
Пример #30
0
 void Update()
 {
     // calculates the rays
     raycasts[0] = new Raycast(transform, Vector3.back, length);
     raycasts[1] = new Raycast(transform, Vector3.down, length);
     raycasts[2] = new Raycast(transform, Vector3.forward, length);
     raycasts[3] = new Raycast(transform, Vector3.left, length);
     raycasts[4] = new Raycast(transform, Vector3.right, length);
     raycasts[5] = new Raycast(transform, Vector3.up, length);
 }
Пример #31
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     startPosition = transform.position;
     raycast       = GetComponent <Raycast>();
     if (canBePurchased)
     {
         GetComponent <Image>().enabled = false;
         turretImage = Instantiate(turretImagePrefab, transform.position, Quaternion.identity);
     }
 }
Пример #32
0
            public static AimBodyPart ChooseBodyPartToAim(Player player, bool forceAimAt = false)
            {
                #region Description

                /*
                 * If forceAimAt is true then aim will return current selected aimed body part
                 * if its false then it will proceede with visual check per body part and will select body part in order
                 * if nothing was found will return Maoci_BodyPart.Null which means no bodypart was found
                 */
                #endregion
                AimBodyPart AimAtPart = AimBodyPart.Head;
                if (Settings.CAimH.KillaMode)
                {
                    for (int i = 0; i < aimHierarhy_Killa.Length; i++)
                    {
                        if (Raycast.isBodyPartVisible(player, (int)aimHierarhy_Killa[i]))
                        {
                            return(aimHierarhy_Killa[i]);
                        }
                    }
                    return(AimBodyPart.Null);
                }
                if (forceAimAt)
                { // force to aim at specific body part
                    if (Settings.CAimH.ForceAimAtBodyPart == "head")
                    {
                        return(AimAtPart);
                    }
                    else if (Settings.CAimH.ForceAimAtBodyPart == "thorax")
                    {
                        return(AimBodyPart.Pelvis);
                    }
                    else // if legs then go head
                    {
                        if (Raycast.isBodyPartVisible(player, (int)AimBodyPart.LCalf))
                        {
                            return(AimBodyPart.LCalf);
                        }
                        if (Raycast.isBodyPartVisible(player, (int)AimBodyPart.RCalf))
                        {
                            return(AimBodyPart.RCalf);
                        }
                    }
                    return(AimBodyPart.Null);
                }
                // artificial aim at visible part of body
                for (int i = 0; i < aimHierarhy.Length; i++)
                {
                    if (Raycast.isBodyPartVisible(player, (int)aimHierarhy[i]))
                    {
                        return(aimHierarhy[i]);
                    }
                }
                return(AimBodyPart.Null);
            }
Пример #33
0
 void Start()
 {
     carControll.enabled = false;
     if (player == null)
     {
         player = GameObject.FindWithTag("Player");
     }
     playerPos      = (Transform)player.GetComponent(typeof(Transform));
     playerControll = (PlayerController)player.GetComponent(typeof(PlayerController));
     RaycastScript  = GameObject.FindWithTag("Manager").GetComponent <Raycast>();
 }
 private void Fall(CreatureStates Creature, Raycast Raycast)
 {
     if (Raycast.SearchForCreature(Vector3.down,Creature.Storey -1) == false &&
         Creature.Storey > 1)
     {
         float x = Creature.transform.position.x;
         float y = Creature.transform.position.y;
         Move(Creature,x,y-FallDistance);
         Creature.Storey--;
     }
 }
Пример #35
0
 public override void Activate(Creature_States Creature, Raycast Raycast, State State, Attack Attack)
 {
     base.Activate (Creature, Raycast, State, Attack);
     if (State == State.Attack_Begin)
     {
         if (Attack.Advisory.Get_Stat(Stat.Energy) >= Siphon_Energy)
         {
             Attack.Advisory.Get_Stat(Stat.Energy, -Siphon_Energy);
             Creature.Get_Stat(Stat.Energy, Siphon_Energy);
         }
     }
 }
Пример #36
0
        void InputJump()
        {
            if (!controlsEnabled || isInWater)
            {
                return;
            }

            if (Raycast.CastVoxel(currentWorld.WorldCamera.Position, new Vector3(0, -1, 0), 2.1f, out RayVoxelOut output))
            {
                rigidbody.AddImpluse(new Vector3(0, 1, 0) * 600);
            }
        }
Пример #37
0
        public Camera(Vector3 Position, Vector3 Target, Vector3 Up)
        {
            this.Position  = Position;
            this.Target    = Target;
            this.Direction = Vector3.Normalize(this.Position - this.Target);

            this.Right = Vector3.Normalize(Vector3.Cross(Up, Direction));
            this.Up    = Vector3.Normalize(Vector3.Cross(this.Direction, this.Right));

            this.View = Matrix.CreateLookAt(Position, Target, Up);
            GroundRay = new Raycast(Position, Position + Vector3.Down * HEIGHT);
        }
Пример #38
0
 // Use this for initialization
 void Start()
 {
     meshRenderer                 = GetComponent <MeshRenderer>();
     spotifyManager               = GameObject.Find("SpotifyManager");
     script                       = spotifyManager.GetComponent <Spotify>();
     recordPlayerScript           = recordPlayer.GetComponent <RecordPlayer>();
     audioVisualizer              = GameObject.Find("AudioVisualizer");
     particleVisualizerGameObject = GameObject.Find("Visualizer Room/ParticleVisualizer");
     particleVisualizer           = particleVisualizerGameObject.GetComponent <ParticleVisualizer>();
     audioVisualizerScript        = audioVisualizer.GetComponent <AudioVisualizer>();
     raycast                      = GameObject.Find("/OVRPlayerController/OVRCameraRig/TrackingSpace/LocalAvatar/controller_right").GetComponent <Raycast>();
 }
Пример #39
0
 // Use this for initialization
 void Start()
 {
     spotifyManager        = GameObject.Find("SpotifyManager");
     spotifyManagerScript  = spotifyManager.GetComponent <Spotify>();
     saveLoad              = spotifyManager.GetComponent <SaveLoad>();
     recommendationDeck    = GameObject.Find("RecommenderDeck");
     recommenderDeckScript = recommendationDeck.GetComponent <RecommenderDeck>();
     raycast        = RaycastGameObject.GetComponent <Raycast>();
     gameObjectName = transform.name;
     //Ignore collisions between grabble and handUI layer, i.e. hand ui and vinyl (they can collide when holding vinyl)
     Physics.IgnoreLayerCollision(8, 11, true);
 }
    /// <summary>
    /// Initialize the class with its type.
    /// </summary>
    /// <param name="type"></param>
    public override void Initialize(UnitType type)
    {
        base.Initialize(type);

        _raycast = GetComponent <Raycast>();

        _neuralNetwork = new NeuralNetwork();
        //_neuralNetwork.Create( new int[]{ 5, 2});

        _raycast.Initialize();

        Reset();
    }
Пример #41
0
    private void Fall(Creature_States Creature, Raycast Raycast)
    {
        if (Raycast.SearchForCreature(Vector2.down,Creature.Storey -1) == false &&
            Creature.Storey > 1)
        {
            float x = Creature.transform.position.x;
            float y = Creature.transform.position.y;
            Vector2 FallLocation = new Vector2 (x, y - FallDistance);

            transform.position = FallLocation;
            Creature.Storey--;
        }
    }
    public override void Activate(CreatureStates Creature, Raycast Raycast, State State)
    {
        base.Activate (Creature, Raycast, State);
        if (Merge.Count < 2)
        {
            Debug.LogError("Need two or more statuses");
        }

        foreach (var i in Merge)
        {
            i.Activate(Creature,Raycast,State);
        }
    }
Пример #43
0
    //    public List <float> Permanent_Stat_Bonus = new List<float>();
    //    public List <float> Temporary_Stat_Bonus = new List<float>();
    //You attach the defect to your weapon
    //Amensia
    public override void Activate(Creature_States Creature, Raycast Raycast, State State, Attack Attack)
    {
        base.Activate (Creature, Raycast, State, Attack);
        if (State == State.Beginning_Of_Turn)
        {
            Turns_Left--;
        }

        if (State == State.End_Of_Turn && Turns_Left < 1)
        {
            Creature.Defects.Remove(this);
            Destroy(this);
        }
    }
 private void AutoSlashDirections(CreatureStates Creature, Raycast Raycast, Vector3 Front, Vector3 OtherFront, Vector3 Direction, Vector3 OtherDirection)
 {
     if (Creature.Front == Front || Creature.Front == OtherFront)
     {
         Raycast.SearchForMultipleDirections(new Vector3[] {Direction,OtherDirection}, Creature.Storey);
         if (Raycast.TargetMultipleCreature.Count == 1)
         {
             Raycast.TargetMultipleCreature[0].Health -= Creature.Damage;
         }
         if (Raycast.TargetMultipleCreature.Count == 2)
         {
             CreatureStates First = Raycast.TargetMultipleCreature[0];
             CreatureStates Second = Raycast.TargetMultipleCreature[1];
             CompareCreaturesHealth(First,Second).Health -= Creature.Damage;
         }
     }
 }
    public override void Activate(CreatureStates Creature, Raycast Raycast, State State)
    {
        if (State == State.Use)
        {
            if (DoubleSided)
            {
                for (int i = 0; i < MoveAmount; i++)
                {
                    Creature.Move(Creature.Front);
                    DirectionalSlash(Creature,Raycast,Vector.Up,Vector.Left);
                    DirectionalSlash(Creature,Raycast,Vector.Up,Vector.Right);
                    DirectionalSlash(Creature,Raycast,Vector.Down,Vector.Left);
                    DirectionalSlash(Creature,Raycast,Vector.Down,Vector.Right);
                    DirectionalSlash(Creature,Raycast,Vector.Left,Vector.Up);
                    DirectionalSlash(Creature,Raycast,Vector.Left,Vector.Down);
                    DirectionalSlash(Creature,Raycast,Vector.Right,Vector.Up);
                    DirectionalSlash(Creature,Raycast,Vector.Right,Vector.Down);
                }
                Creature.Move(Creature.Front);
            }

            if (Auto)
            {
                for (int i = 0; i < MoveAmount; i++)
                {
                    AutoSlash (Creature, Raycast);
                }
                Creature.Move(Creature.Front);
            }

            if (!DoubleSided && !Auto)
            {
                for (int i = 0; i < MoveAmount; i++)
                {
                    Creature.Move(Creature.Front);
                    DirectionalSlash(Creature,Raycast,Vector.Up,DirectionToHit[0]);
                    DirectionalSlash(Creature,Raycast,Vector.Down,DirectionToHit[1]);
                    DirectionalSlash(Creature,Raycast,Vector.Left,DirectionToHit[2]);
                    DirectionalSlash(Creature,Raycast,Vector.Right,DirectionToHit[3]);
                }
                Creature.Move(Creature.Front);
            }
        }
    }
Пример #46
0
    public override void Activate(Creature_States Creature, Raycast Raycast, System_Control.State State, Attack Attack)
    {
        base.Activate (Creature, Raycast, State, Attack);
        Passives.ForEach(p => p.Activate(Creature,Raycast,State,Attack));

        if (State == State.Attack)
        {
            if (Creature.Get_Stat(Stat.Energy) > Get_Stat(Stat.Energy))
            {
                Creature.Get_Stat(Stat.Energy,-Get_Stat(Stat.Energy));
            }
        }

        if (State == State.Attack_Begin)
        {
            Attack.Dont_Negate_Energy = false;
            Calculate_Bonus_Multipler ();
            Attack.Damage_Bonus_Multiplier.Add(Damage_Bonus_Multiplier);
        }
    }
 public virtual void Activate(CreatureStates Creature, Raycast Raycast, State State)
 {
 }
 protected void DirectionalSlash(CreatureStates Creature,Raycast Raycast, Vector3 FacingDirection, Vector3 SlashDirection)
 {
     if (Creature.Front == FacingDirection)
         VanillaSlash(Creature,Raycast,SlashDirection);
 }
Пример #49
0
 public Attack(Creature_States Assign_Creature, Raycast Assign_Creature_Raycast, Creature_States Assign_Advisory)
 {
     Creature = Assign_Creature;
     Creature_Raycast = Assign_Creature_Raycast;
     Advisory = Assign_Advisory;
 }
Пример #50
0
 protected override void Start()
 {
     base.Start ();
     Raycast = GetComponent<Raycast>();
     SpriteRenderer = GetComponent<SpriteRenderer>();
 }
 private void AutoSlash(CreatureStates Creature, Raycast Raycast)
 {
     Creature.Move(Creature.Front);
     AutoSlashDirections(Creature,Raycast,Vector.Up,Vector.Down,Vector.Left,Vector.Right);
     AutoSlashDirections(Creature,Raycast,Vector.Left,Vector.Right,Vector.Up,Vector.Down);
 }
Пример #52
0
 void Start()
 {
     MoveToStartingPosition ();
     speed = GetComponent<BaseStats> ().movementSpeed;
     tempPosition = transform.position.x;
     controller  = GetComponent<CharacterController>();
     raycast = GetComponentInChildren<Raycast> ();
     _animator = GetComponentInChildren<Animator>();
 }
 private void RecordHeight(CreatureStates Creature, Raycast Raycast)
 {
     if (Raycast.SearchForCreature(Vector3.down,Creature.Storey -1))
         FallDistance = Raycast.TargetCreature.Height;
 }
Пример #54
0
 public virtual void Activate(Creature_States Creature, Raycast Raycast, State State, Attack Attack)
 {
 }
Пример #55
0
    // Use this for initialization
    void Start()
    {
        anim = gameObject.GetComponent<Animator> ();

        cast = gameObject.GetComponent<Raycast> ();
        acceleration = 0.67f;
        targetSpeed = 5f;
        brakeSpeed = 1.00f;
        rigidbody2D.gravityScale = 2.1f;
    }
 protected override void Start()
 {
     base.Start ();
     Raycast = GetComponent<Raycast>();
 }